How to write to SQL-database in a routine?

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Jdrost
Participant
Posts: 17
Joined: Wed Jun 28, 2006 3:32 am

How to write to SQL-database in a routine?

Post by Jdrost »

Hello,

I want to write directly to a SQL-database in a DS-routine. Does anyone have an example how to do this?
Kind regards,

Johannes Drost
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Which database? The easiest is to use a CALL DSExecute(...) API to run a system command, such as sqlplus, isql, sqlcmd, dbaccess, etc. Just formulate the DML or use an existing script and invoke it using the command line program.

Please don't do this to avoid using an ODBC/OCI stage for loading data. I'm assuming you mean to write a row into some table. If you're loading data as part of the ETL process, stick to using the tool.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

The whole purpose of DataStage is to do this for you. You lose a lot of the beauty of DataStage when you go around it. The only reason to do this is to do a pure update. Please explain why you feel you need to go around DataStage.
Mamu Kim
DeepakCorning
Premium Member
Premium Member
Posts: 503
Joined: Wed Jun 29, 2005 8:14 am

Post by DeepakCorning »

I agree... :) It is like creating another tool with in Datastage to generate SQLs :wink:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Doing it from a routine incurs one of two fairly severe penalties. Either the routine executes a shell script (with all the overheads of establishing and managing a new shell and return structure), or the routine uses BCI functions (which involves paying for a Data Direct ODBC licence). Why re-invent the wheel?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Jdrost
Participant
Posts: 17
Joined: Wed Jun 28, 2006 3:32 am

Post by Jdrost »

kcbland wrote:Which database? The easiest is to use a CALL DSExecute(...) API to run a system command, such as sqlplus, isql, sqlcmd, dbaccess, etc. Just formulate the DML or use an existing script and invoke it using the command line program.

Please don't do this to avoid using an ODBC/OCI stage for loading data. I'm assuming you mean to write a row into some table. If you're loading data as part of the ETL process, stick to using the tool.
How do I handle userID and password for the server the database is on?
Kind regards,

Johannes Drost
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

However you like. They can be passed (as command line arguments) from DataStage to the shell script, for one example. They could be environment variables (perhaps encrypted) for another example.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply