How can i use stored procedures in PX.

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
Nripendra Chand
Premium Member
Premium Member
Posts: 196
Joined: Tue Nov 23, 2004 11:50 pm
Location: Sydney (Australia)

How can i use stored procedures in PX.

Post by Nripendra Chand »

Hi All,

How can i use stored procedures (For Oracle database) in PX? I also want to pass parameters to the procedure.


-Nripendra
sudharsanan
Participant
Posts: 64
Joined: Fri Jul 16, 2004 7:53 am

Post by sudharsanan »

I haven't used store procedure in my project.. This topic has been discussed already i am give that link...viewtopic.php?t=91200&highlight=Stored+Procedure
Nripendra Chand
Premium Member
Premium Member
Posts: 196
Joined: Tue Nov 23, 2004 11:50 pm
Location: Sydney (Australia)

Post by Nripendra Chand »

How can i solve this problem:

Country_Id is a job parameter. If it is blank then table should return all the records else values corresponding to country_id should be returned.
Country_Id is a column in the table.

-Nripendra
sudharsanan
Participant
Posts: 64
Joined: Fri Jul 16, 2004 7:53 am

Post by sudharsanan »

Are asking about how to write a Stored Procedure for your condition?...
sudharsanan
Participant
Posts: 64
Joined: Fri Jul 16, 2004 7:53 am

Post by sudharsanan »

I am giving a sample Store Procedure where you pass the Country_id
Open a cursor to store all the values there..

CREATE OR REPLACE PROCEDURE <Procedure_Name>(Country_id NUMBER) IS
BEGIN

IF Country_id IS NULL THEN

Cursor Country_out is Select * from table;
Else

Cursor Country_out is Select * from table where Country_id = <Country_id>

RETURN;
END IF;


Please modify the code according to your need... Just pass the country_id as the input and verify it in the procedure...
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

It is so funny that I replied to an identical topic in the Server section a few minutes ago.

The answer was:

Use an OR clause as below

Select *
From Country
Where ('#CountryParameter#' = '')
Or (ContryCode = '#CountryParameter#')
bgs
Participant
Posts: 22
Joined: Sat Feb 05, 2005 9:43 pm

Post by bgs »

Either you can call the procedure in a select statement or you can write a shell script which calls the procedure.And you can call the shell script in external filter stage or you can create a wrapper stage
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
you didn't mention if your on a 7.5 release of DS?
if so there is a new stored procedure stage that supports also output parameters.
though it seems to run via ODBC.

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
Madhav_M
Participant
Posts: 43
Joined: Sat Jul 10, 2004 5:47 am

Post by Madhav_M »

Is there is any ways to import stored procedure into a routine??
elavenil
Premium Member
Premium Member
Posts: 467
Joined: Thu Jan 31, 2002 10:20 pm
Location: Singapore

Post by elavenil »

Any SQL statements including stored procedures can be executed from Before/After SQL of any DB stages.

Regards
Saravanan
Post Reply