Can we create and use Temporary tables in DataStage? - odbc

Is it possible to create and/or use temporary tables in the ODBC connector stage of the DataStage?
I'm trying to update the data using a #Temp table in the join statement immediately after populating the Temp table.
I had looked according to the error form the job's log file but couldn't understand what it says,
Error message:
Unrecognized argument: variant='3.5\',
library=ccodbc,
version=1.0,
variantlist=\'V1;3.5::ccodbc\',
versionlist=\'1.0\',
name=ODBCConnector
}'
SAX parser exception thrown: The input ended before all started tags were ended. Last tag started was 'before' (CC_PropertySet::fatalError, file CC_PropertySet.cpp, line 2,266)

Got a solution!
Yes, we can use #Temp tables of SQL Server in DataStage ODBC stage, the query was absolutely perfect but the thing is DataStage couldn't prase the SQL Query. It considered it as DataStage parameter (since parameters in DataStage were bounded with #ParameterName#) So the DataStage compiler consider it as a incomplete parameter and thrown the error as above.
Solution: Use [ #Temp_Table ] to solve the issue.

Related

dbWriteTable: Only an ET or null statement is legal after a DDL Statement.)

I am able to read data. However, when writing data to Teradata database, I get the following error:
Error in .verify.JDBC.result(s, "Unable to create JDBC prepared
statement ", :
Unable to create JDBC prepared statement INSERT INTO
dl_nbu.alex_test2 VALUES(?,?) ([Teradata Database]
[TeraJDBC 16.10.00.07] [Error 3932] [SQLState 25000] Only an ET or
null statement is legal after a DDL Statement.)
Here is my code:
dbWriteTable(tdConnection, "dl_nbu.alex_test2", all_files4)
Hard to give an answer without details. But check the RJDBC help page:
Due to the fact that JDBC can talk to a wide variety of databases, the SQL dialect understood by the database is not known in advance. Therefore the RJDBC implementation tries to adhere to the SQL92 standard, but not all databases are compliant. This affects mainly functions such as dbWriteTable that have to automatically generate SQL code. One major ability is the support for quoted identifiers. The SQL92 standard uses double-quotes, but many database engines either don’t support it or use other character. The
identifier.quote parameter allows you to set the proper quote character for the database used. For example MySQL would require identifier.quote="`". If set to NA, the ability to quote identifiers is disabled, which poses restrictions on the names that can be used for tables and fields. Other functionality is not affected.
Try this and see what happens:
allfiles4 -> allFilesFour
dbWriteTable(tdConnection, "testTwo", allFilesFour)
If works, then the problem is in the quote identifier. Change the line where you make the connection to something like:
tdConnection <- dbConnect( JDBC( identifier.quote = "`" ), ...
Check this post: Do different databases use different name quote?

ORACLE 11g Know Insert Record Details which Failed to insert

I have started auditing insert records by user on failure to any table in my oracle 11g Database. I have used following command to do the same.
AUDIT INSERT ANY TABLE BY SHENA BY ACCESS WHENEVER NOT SUCCESSFUL;
I would like to know whenever the record insert will fail, Can i know what was the records which failed to insert into table.
Where we can see such information. Or if you know any other way of auditing of the same please suggest. One way which i know is to write a trigger on insert. In that trigger handle insert failure EXCEPTION and save those values to some table.
Use SQL Loader Utility with following control file format.
options(skip=1,rows=65534,errors=65534,readsize=16777216,bindsize=16777216)
load data
infile 'c:\users\shena\desktop\1.txt'
badfile 'C:\Users\shena\Desktop\test.bad'
discardfile 'C:\Users\shena\Desktop\test.dsc'
log 'C:\Users\shena\Desktop\test.log'
append
into table ma_basic_bd
fields terminated by '|' optionally enclosed by '"' trailing nullcols
(fs_perm_sec_id,
"DATE" "to_date(:DATE,'YYYY-MM-DD')",
adjdate "to_date(:adjdate,'YYYY-MM-DD')",
currency,
p_price,
p_price_open,
p_price_high,
p_price_low,
p_volume)
You are requested to use the conventional path loading so that we can get the rejected(rejected because of datatype mismatch and business rule violation) records in .bad file. Conventional path loading is a default option.
Following URL can be used for the detailed knowledge.
https://youtu.be/eovTBGAc2RI
Total 4 videos are there. Very helpful.

flywaydb: Command Line migrate limitation

I am planning to use flywayDb to automate SQL script migration part of my project for the same purpose i tried to test it but it failed one one SQL script saying some Invalid Character error which I am unable to identify where as same script is working fine inside AQT/SQL Developer.
Do we have any restrictions or standards need to follow while using command line migrate?
I have doubt on some values which are using single quote and slash symbols... like below
'Family Member''s' OR SOME \ TEXT
Please suggest.
I was able to find issue problem was with one merge statement in which field value and field name was not having space
hence flyway DB was throwing error...I added one space and it worked. Where as without removing space works fine in AQT and sqldeveloper
MERGE INTO TEST.question ques USING
(SELECT '2004'question_id,'Details (Header)' question_text FROM DUAL) S
ON (ques.Question_id = S.Question_id)
WHEN MATCHED THEN UPDATE
SET
ques.text=S.text;
Correct one
MERGE INTO TEST.question ques USING
(SELECT '2004' question_id,'Details (Header)' question_text FROM DUAL) S
ON (ques.Question_id = S.Question_id)
WHEN MATCHED THEN UPDATE
SET
ques.text=S.text;

java.sql.SQLSyntaxErrorException: ORA-04098: trigger 'MYTABLE.MY_SEQUENCE_ID' is invalid and failed re-validation

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).

SQL Server Error: "Cannot use empty object or column names"

I get the following error:
Cannot use empty object or column names. Use a single space if necessary.
Msg 1038, Level 15, State 3, Line 1
and the query command looks like:
SELECT TOP 100 PERCENT
[].[cms_page].[pa_id], [].[cms_page].[pa_key],
[].[cms_page].[pa_title], [].[cms_page].[pa_keywords],
[].[cms_page].[pa_description], [].[cms_page].[pa_header],
[].[cms_page].[pa_created], [].[cms_page].[pa_modified],
[].[cms_page].[pa_language] FROM [cms_page]
WHERE
[cms_page].[pa_key] = #pa_key0
ORDER BY
[pa_id] ASC;
Strange indeed. Why does this happen? I'm using SubSonic 2.1.
Connectionstring:
<add name="OCDB" connectionString="Network Library=DBMSSOCN;Data Source=127.0.0.1,1433;Initial Catalog=test_db;User ID=test;Password=testpwd"/>
Edit: Well the solution was just to simply generate and rebuild the Data Access Layer and I was good to go.
You seem to be using a 3 part name with part of it empty, i.e. '[].'
It looks as though the query text is being constructed with an empty table schema.
Those empty [] square brackets should contain something like "dbo" to make the query syntactically valid. I don't know enough about SubSonic to give you a code sample though.
I'm not familiar with SubSonic, but have you tried a simpler query to test if you have your syntax correct? Does this query even work in SQL Server (Management Studio / Query Analyzer)?
Just looking at this from the perspective of SQL Server, you are using way too many brackets. If I was writing that query in SQL Server, it would look more like what I wrote below. I'm not sure about the variable #pa_key0, is this query part of a stored procedure or does SunSonic replace this variable when the query is ran?
SELECT
pa_id,
pa_key,
pa_title,
pa_keywords,
pa_description,
pa_header,
pa_created,
pa_modified,
pa_language
FROM
cms_page
WHERE
pa_key = #pa_key0
ORDER BY
pa_id ASC;
I think you need to set the schema for Subsonic to use. This thread seems to have some information:
Subsonic - How to use SQL Schema / Owner name as part of the namespace?

Resources