how to read records from DB2 table through routines

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ragunathan13
Participant
Posts: 50
Joined: Mon Sep 25, 2006 11:18 pm
Location: Chennai
Contact:

how to read records from DB2 table through routines

Post by ragunathan13 »

Hi to all,
Can anybody tell how to get the records from DB2 table through routines?
if possible, pls send the routine.

Advanced Thanks.
Ragunathan J.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

It is very much like you execute your OS command.
You have Command line call facility avaialble in DB2.
>db2 connect to database.....
>db2 "select * from .....";
You need to wrap this command as the OS comand call.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi Ragunathan,
Pls delete the other duplicate post created on the Server forum.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ragunathan13
Participant
Posts: 50
Joined: Mon Sep 25, 2006 11:18 pm
Location: Chennai
Contact:

Post by ragunathan13 »

hi kumar..

actually my req. is, using routines i have to extract the records from db2 table

Regards
Ragunathan J
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Are you refering to BASIC Routine?
If so Call DSExecute can be used to call OS commands. Through which you can call DB2 commands.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ragunathan13
Participant
Posts: 50
Joined: Mon Sep 25, 2006 11:18 pm
Location: Chennai
Contact:

Post by ragunathan13 »

hi kumar

yes... but i don't know how to connect with db2..

can u give some sample code for this pl...

Regards
Ragunatha J
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Find the full detail of CLP here.
http://publib.boulder.ibm.com/infocente ... 010412.htm
And revert back if you still find any further issues.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You will need to issue a command line:

db2 connect {options}
db2 set schema {options}
db2 SELECT {blah blah, options}
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ragunathan13 wrote:actually my req. is, using routines i have to extract the records from db2 table
Perhaps you could share with us why you 'need' to do this, why the requirement? Then we can tell you why you don't want to do it that way and give you an alternative or two.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ragunathan13
Participant
Posts: 50
Joined: Mon Sep 25, 2006 11:18 pm
Location: Chennai
Contact:

Post by ragunathan13 »

hi chulett

Actually my requirement is read the "jobnames" from db2 table one by one and run those jobs sequentially using routine.

Thanks and regards
Ragunathan J
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Read them in a job using the DB2 stage and then use the UtilityRunJob routine (conveniently located in the sdk\Utilities branch) in a transformer.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply