Stored Procedure

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
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Stored Procedure

Post by cosec »

How do I do a stored procedure to do the following

IF #RERUN_IND#='Y' THEN

DELETE FROM TBL_A WHERE TBL_A.MONTH=#MONTH_IND#;

ELSE 0


Pls Advice

Thanks
sachin1
Participant
Posts: 325
Joined: Wed May 30, 2007 7:42 am
Location: india

Re: Stored Procedure

Post by sachin1 »

hello,

you have to create a procedure in database having input parameters that you require for your processing.

Next in Stored_Procedure stage goto --> syntax tab -->give the name for procedure --> uncheck generate procedure call ---> then call your procedure like for example

BEGIN p2('#val#'); END;

#val# is the input parameter for job which could be directly used as a value in your procedure.
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Re: Stored Procedure

Post by cosec »

Hello sachin,
Thanks but I am using the server edition and I believe the stored_proc is not available....

so can I use the statement I mentioned earlier in a routine ? is the sysntax correct ?
sachin1 wrote:hello,

you have to create a procedure in database having input parameters that you require for your processing.

Next in Stored_Procedure stage goto --> syntax tab -->give the name for procedure --> uncheck generate procedure call ---> then call your procedure like for example

BEGIN p2('#val#'); END;

#val# is the input parameter for job which could be directly used as a value in your procedure.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Re: Stored Procedure

Post by JoshGeorge »

The ODBC stage has stored procedure as one of its options in server edition.
cosec wrote:
Thanks but I am using the server edition and I believe the stored_proc is not available....
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Re: Stored Procedure

Post by cosec »

Ok thanks ...but can I also use this SQL statement in a routine ?
JoshGeorge wrote:The ODBC stage has stored procedure as one of its options in server edition.
cosec wrote:
Thanks but I am using the server edition and I believe the stored_proc is not available....
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

I reccomend to search the forum. Calling stored procedure/ Executing SQL thru routine has been discussed many times out here.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
sachin1
Participant
Posts: 325
Joined: Wed May 30, 2007 7:42 am
Location: india

Re: Stored Procedure

Post by sachin1 »

i am using Datastage server 7.5 (server edition)... we have a stored procedure stage.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Why not just create a job to delete the rows? Use user-defined SQL, supply the date (as a job parameter) and refer to this in the WHERE clause of your DELETE statement.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

Yes that's possible...but I would like to do it in the same job...

ray.wurlod wrote:Why not just create a job to delete the rows? Use user-defined SQL, supply the date (as a job parameter) and refer to this in the WHERE clause of your DELETE statement. ...
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Then why not do it in the 'same job'.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

JoshGeorge wrote:Then why not do it in the 'same job'.
Yes I am researching on how to use the stored procedure..

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

Post by ray.wurlod »

You DON'T NEED a stored procedure!!! Just use a DELETE command as the user-defined SQL.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

ray.wurlod wrote:You DON'T NEED a stored procedure!!! Just use a DELETE command as the user-defined SQL. ...
I tried the delete command in Output Link 1 and the insert in Output Link 2. But when I do this The table gets locked...


how can i prevent this...? the transaction size was set to 1 in the DB2 stage attached to Output link 1
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

By not doing it in the same job, as originally advised.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or use a single target stage, not two.
-craig

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