Filter a Select based on Input

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
kirkboy
Participant
Posts: 6
Joined: Tue Aug 25, 2009 11:59 am

Filter a Select based on Input

Post by kirkboy »

I need to use the results from one Oracle stage to be used to filter the select statement on a following oracle stage. How can I use input on an oracle stage to filter the select statement?
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

If both the tables are from same database then do it in Sql.

Else you can do lookup using transformer
You are the creator of your destiny - Swami Vivekananda
kirkboy
Participant
Posts: 6
Joined: Tue Aug 25, 2009 11:59 am

Post by kirkboy »

More details:

Table A's output is already being transformed, altering the data before it is joined with Table B. I am currently querying table b into a hash table, then joining it to Table A in a Transform stage.

The problem is that the query on table B is a full table scan... because I have no criteria on it. Pulling a full table scan into a hash before using a transform to select a handful of records is terribly inefficient.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Can you not load the results from Table A into a work table so that downstream from there you can join it to Table B to constrain the query?
-craig

"You can never have too many knives" -- Logan Nine Fingers
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post by arunkumarmm »

If both the table are in different database, I believe the best way would be to do it in a query.

Ask your DBA to create a dblink for you.
Arun
kirkboy
Participant
Posts: 6
Joined: Tue Aug 25, 2009 11:59 am

Post by kirkboy »

As I understand the replies:

If same database, you must join inside the original SQL (an option, so long as you are NOT altering the data of one query via Datastage stages prior to using it as criteria for a later SQL)

If different databases of the same type, oracle dblinks can be used.

If two seperate database types are being used, a load table can be used as a work around.

So the answer is NO, Datastage does not have a way of filtering a query based on input from upstream.
kirkboy
Participant
Posts: 6
Joined: Tue Aug 25, 2009 11:59 am

Post by kirkboy »

I need another workaround, similar issue.

I am running a stored procedure on an oracle database which writes a CLOB file to a table, then returns a pointer to where the CLOB was written.

After executing the procedure in the stored_procedure stage, and sending the output to a HASH, I need to pull data from the CLOB into datastage for processing.

Pulling data into the CLOB is not the issue, the question is, how do I filter my query to pull the clob I need, based on the pointer index returned from the Stored Procedure Stage?

Stored Procedure->index->query based on index?

If datastage does not support filtering a database query based on criteria from an input link, what is my workaround?


Edit: I think my solution might be to Create two jobs and a Sequence. The first job executes the procedure and returns the values to the Sequence. The sequence passes the values to the second job, which then uses the Parameters the sequence passed it to filter the query against the CLOB table.
Post Reply