I have the below script in the Source Editor in a SSIS package and I get an error. I change to a Select * and it works. I'm not sure why this is not working. It works in P/SQL. Any help would be appreciated!
This works in my package:
select * from Test
This does not work in my package (but works in PL/SQL) and I get the below error.
select * from (select id, color, shape,
dense_Rank () Over (Partition By id order by id desc as SeqRank)
) x
Error: 0xC0202009 at Data Flow Task, OLE DB Source [111]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14.
Best approach for this questions is instead of creating a subquery one could create a CTE. A CTE is compatiable with SSIS.
Related
I already downloaded the latest SQLite.dll from SQLite Download Page and try to load it using TFDPhysDriverLink.VendorLib
But when I run the app, which contains the following code:
procedure TForm1.FormCreate(Sender: TObject);
begin
FDConnection1.Close;
FDPhysSQLiteDriverLink1.Release;
FDPhysSQLiteDriverLink1.VendorLib:= 'Path\SQLite3.dll';
FDQuery1.Open('SELECT *, ROW_NUMBER() OVER() Col FROM TableName');
end;
It throws:
[FireDAC][Phys][SQLite] ERROR: near "(": syntax error
Which means that the window function ROW_NUMBER() is not recognized.
What I'm doing wrong?
How can I force FireDAC to use the latest SQLite.dll?
SQLite do not support ROW_NUMBER.
Look at the answers for this question, you'll probably find something to replace ROW_NUMBER.
If you get this error, then the SQlite3.dll was loaded just fine.
Just use the RowID field, which is always existing for any standard SQLite3 table - unless you explicitly created them with CREATE TABLE WITHOUT ROWID statement.
So I would just write:
FDQuery1.Open('SELECT *, RowID FROM TableName');
Note that if there is an explicit INTEGER PRIMARY KEY column in your table, it will in fact map the internal RowID column. Check the SQLite3 documentation for how this works.
I wanted to fetch the currently executing queries in Teradata and when I ran the below SQL and I got the error message as 'Failed 9881 : Function 'MonitorSQLText' called with an invalid number or type of parameters'. I am using TD 14.10
SELECT * FROM TABLE (MonitorSQLText(-1, '*', 0)) AS T2;
Please help me with this query.
MonitorSQLText can only be applied to a single session.
To get info for all sessions you must use MonitorSession(-1, '*', 0), when you do it in a Stored Procedure you can run it as a cursor and process each row.
With the release of dplyr 0.7.0, it is now supposedly easy to connect to Oracle using the odbc package. However, I am running into a problem accessing tables not inside the default schema (for me it is my username). For example, suppose there is the table TEST_TABLE in schema TEST_SCHEMA. Then, example SQL syntax to get data would be: select * from TEST_SCHEMA.TEST_TABLE'.
To do the same in `dplyr, I am trying the following:
# make database connection using odbc: [here's a guide][1]
oracle_con <- DBI::dbConnect(odbc::odbc(), "DB")
# attempt to get table data
tbl(oracle_con, 'TEST_SCHEMA.TEST_TABLE')
Now, this leads to an error message:
Error: <SQL> 'SELECT *
FROM ("TEST_SCHEMA.TEST_TABLE") "zzz12"
WHERE (0 = 1)'
nanodbc/nanodbc.cpp:1587: 42S02: [Oracle][ODBC][Ora]ORA-00942: table or view does not exist
I think the problem here is the double quotation marks, as:
DBI::dbGetQuery(oracle_con, "select * from (TEST_SCHEMA.TEST_TABLE) where rownum < 100;")
works fine.
I struggled with this for a while until I found the solution at the bottom of the introduction to dbplyr. The correct syntax to specify the schema and table combo is:
tbl(oracle_con, in_schema('TEST_SCHEMA', 'TEST_TABLE'))
As an aside, I think the issue with quotation marks is lodged here: https://github.com/tidyverse/dplyr/issues/3080
There are also the following alternate work-arounds that may be suitable depending on what you wish to do. Since the connection used DBI, one can alter the schema via:
DBI::dbSendQuery(oracle_con, "alter session set current_schema = TEST_SCHEMA")
after which tbl(oracle_con, 'TEST_TABLE') will work.
Or, if you have create view privileges, you can create a "shortcut" in your default schema to any table you are interested in:
DBI::dbSendQuery(oracle_con, "CREATE VIEW TEST_TABLE AS SELECT *
FROM TEST_SCHEMA.TEST_TABLE")
Note that the latter may be more suitable for applications where you wish to copy local data to the database for a join, but do not have write access to the table's original schema.
I get this error from Progress database when running the following query using ODBC:
SELECT distinct Table.column,
{ fn CONVERT(SUBSTRING(Table.ProblematicColumn, 1, 60), SQL_VARCHAR)} as test
FROM PUB.Table
WHERE ( Table.id IN (
SELECT Table.id
FROM PUB.Table
) )
I know it's possible to fix it using the DBTools. However, I run queries against multiple Progress databases of multiple clients, so it's not practical to do this every time.
Also, for some reason, the ODBC client I'm using (PHP), doesn't show any error when this happens. Instead, it returns an empty result.
The convert I did to a VAR_CHAR of 60 character did help until I added the sub-query. When the sub-query is there, I get again the same error.
Interestingly enough, when the 'distinct' is not there, it's working. But I do need the distinct.
Edit: The question is how can I execute this query without fixing the width column with DBTool.
It took a few minutes to find an answer. The problem appears to be in the OE10 SQL broker not handling the sub select in the where clause. This alternative using an inner join to a sub select looks to be equivalent to me. I tested it, it does work. Replacing the SQL client will do nothing, the error occurs in the OpenEdge SQL broker: I get the same error using the OpenEdge JDBC driver.
SELECT distinct Table.column,
{ fn CONVERT(SUBSTRING(Table.ProblematicColumn, 1, 60), SQL_VARCHAR)} as test
FROM PUB.Table inner join (select id from PUB.Table) t2 on Table.id = t2.id
Upgrade to OE 11.6.
There are options in 11.6 to automatically and silently truncate the data so that you will not get an error.
"Autonomous Schema Update"
https://community.progress.com/community_groups/openedge_rdbms/f/18/t/19534
I am creating this oracle 11g statement inside a java String and then executing it in sql developer. I tried running it on the database and got a warning when the trigger
is created. But, when run from the code, I get the error mentioned in my title.
Please tell me where is the mistake and how i can fix it ?
CREATE OR REPLACE TRIGGER myschema.my_sequence_id BEFORE INSERT ON myschema.mytable
FOR EACH ROW BEGIN SELECT my_sequence_id.nextval INTO :new.mycolumn FROM DUAL; end; /
Thanks in advance !
You can't have a trigger named my_sequence_id if you already have a sequence my_sequence_id. They share the same namespace. Your trigger would need to be named something other than the name of the sequence (or any other object in the schema).