Read SQL into Datastage job

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
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

Read SQL into Datastage job

Post by pavan_test »

Hi All,

I have a unique situation where a sql is stored in Oracle table.
The table has 4 columns, colA, colB, col C and colD.

The sql is stored in col D in the table.

sql statement in Col D might be something like this,

select xxx,yzz,ymz from table xx where condition 1= condition2

datastage has to read Col D (which contains sql) from the table into the ETL job and process the data.

Can someone please let me know how can I achieve this using Oracle Enterprise Edition stage, on aix server and datastage v8.1

Thanks
Pavan
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Post by kandyshandy »

How many records in the oracle table whose col D has (a single SELECT) SQL? one or many?
Kandy
_________________
Try and Try again…You will succeed atlast!!
v2kmadhav
Premium Member
Premium Member
Posts: 78
Joined: Fri May 26, 2006 7:31 am
Location: London

Post by v2kmadhav »

are the number of columns in the sql query dynamic ? if its always 3 columns? What do you mean by process the data ? Would it be different for each table the data is extracted from ?

You could fetch the value in column D querying this table from a sequencer and pass the output sql as a parameter to the job that reads using a oracle stage perhaps using RCP...
v2kmadhav
Premium Member
Premium Member
Posts: 78
Joined: Fri May 26, 2006 7:31 am
Location: London

Post by v2kmadhav »

are the number of columns in the sql query dynamic ? if its always 3 columns? What do you mean by process the data ? Would it be different for each table the data is extracted from ?

You could fetch the value in column D querying this table from a sequencer and pass the output sql as a parameter to the job that reads using a oracle stage perhaps using RCP...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Not easy, and I'd probably guess impossible in a single job. You can read the SQL from the table in one job, load it into that job's user status area, and read that when setting a job parameter to contain the SQL in a second job. Use the first job's $UserStatus activity variable to get the SQL 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

... or write it to a file and have the second job read that 'SQL File'.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

Read SQL from datastage job

Post by pavan_test »

There will be only 1 record in the oracle table (lets say table name is myz) whose Col D has selct query.

The select query in Col D is not querying the same table. The select query will return 3 columns. The query is static for now, when there is a change, it might be in the "where" clause in the sql statement but not in select statement.

select xxx,yzz,ymz from table xx where condition 1= condition2

Thanks
Pavan
kandyshandy
Participant
Posts: 597
Joined: Fri Apr 29, 2005 6:19 am
Location: Singapore

Re: Read SQL from datastage job

Post by kandyshandy »

pavan_test wrote:There will be only 1 record in the oracle table (lets say table name is myz) whose Col D has selct query.
Then Craig/Ray has given you 2 options.

If it is more than one SQL with delimiter ';', then i don't think you can execute in enterprise stage, unless you implement a loop to pass one SQL at a time to enterprise stage.
Kandy
_________________
Try and Try again…You will succeed atlast!!
Post Reply