Multiple queries in ODBC Stage

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
dganeshm
Premium Member
Premium Member
Posts: 91
Joined: Tue Aug 11, 2009 3:26 pm

Multiple queries in ODBC Stage

Post by dganeshm »

Here are the two queries I have written in the ODBC stage in a Server job..

INSERT INTO DATALOAD(RECORDKEY, RECORDTYPE, MX_MESSAGE, DSJOBNAME) VALUES (?,?,?,?);

UPDATE DATALOADHEADER SET ERRORCOUNT = 0 WHERE JOBNAME = DSJOBNAME;

The error I am getting is :

DSD.BCIOpenW call to function SQLPrepare failed.

UPDATE DATALOADHEADER SET ERRORCOUNT = 0 WHERE JOBNAME = DSJOBNAME
SQLSTATE=S0022, DBMS.CODE=207
[DataStage][SQL Client][ODBC][IBM(DataDirect OEM)][ODBC SQL Server Driver][SQL Server]Invalid column name 'DSJOBNAME'.

----------------------

DSJOBNAME is in the input link to ODBC stage , how can I overcome this?
Regards,
Ganesh
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You need to use parameter markers in your update DML just like is shown for the insert. The problem is going to be they are positional in ODBC so if you place a single ? there it will substitute the value from the first column from the link.

You'll need to rearrange the columns so that the value for DSJOBNAME is first and then see if this works:

Code: Select all

INSERT INTO DATALOAD(DSJOBNAME, RECORDKEY, RECORDTYPE, MX_MESSAGE) VALUES (?,?,?,?); 

UPDATE DATALOADHEADER SET ERRORCOUNT = 0 WHERE JOBNAME = ?; 
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:? Right after I posted this I realized you weren't trying to emulate the 'insert else update' action the stage can do for you but rather than delete my original post (which has valid information in it) I decided to leave it and add this instead.

Two separate actions would use two links. They can both go into the same stage but one would be for the insert with 4 columns and the one for the update would only have the single column. Let the stage generate the DML for you.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dganeshm
Premium Member
Premium Member
Posts: 91
Joined: Tue Aug 11, 2009 3:26 pm

Post by dganeshm »

Thanks chulett, thats a good learning for the day...
Regards,
Ganesh
Post Reply