Single stage for running script

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
Munish
Participant
Posts: 89
Joined: Sun Nov 19, 2006 10:34 pm

Single stage for running script

Post by Munish »

Hi All,
I need to
run SQL sripts to update tables in Oracle (Update flag to 'Y')
after successful ETL run.

I want to do in one stage.
What might be best options.
1. Using 'Execute Command' activity.
2. Using Routine.
or
something else.

Thanks for your advice(s) in advance,
Regards,
Munish
MK
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You can use either one. You might have more control in a routine as your can do error handling and produce appropriate messages in logs. If you dont need all that, then go for execute command stage.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Why not have a job that does this? Why do you 'need' to run sql scripts?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Munish
Participant
Posts: 89
Joined: Sun Nov 19, 2006 10:34 pm

Post by Munish »

Why not have a job that does this? Why do you 'need' to run sql scripts?
How to do that in a single job.
OCI stage does not do anything of its own. I need to add another stage to OCI to get that working.

Is there a way out.
I was thinking of using scripts just to get away with this, otherwise I am more than happy with using a job.

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

Post by ray.wurlod »

Row Generator stage can generate as many 'Y' values as you desire.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Munish
Participant
Posts: 89
Joined: Sun Nov 19, 2006 10:34 pm

Post by Munish »

My ETL has 40 sequences.
This is going to be the last sequence where once all the prior (40) sequences finishes successfully.
I need to update column in 2 tables in Oracle with value as 'Y' and 'Successful'.

I was just wondering what might be the best way to do it.
Thanks,
Munish
MK
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Munish wrote:
Why not have a job that does this? Why do you 'need' to run sql scripts?
How to do that in a single job.
OCI stage does not do anything of its own. I need to add another stage to OCI to get that working.
As Ray noted, a Row Generator can feed the stage. In a Server solution, all you need is a Transformer before the OCI stage to feed it rows. The technique has been discussed here many times. Or if you'd rather, select rows from dual to feed it. Several ways to accomplish this.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Munish
Participant
Posts: 89
Joined: Sun Nov 19, 2006 10:34 pm

Post by Munish »

Thanks Champs,
I got it.
Closing the thread.
Regards,
Munish
MK
Munish
Participant
Posts: 89
Joined: Sun Nov 19, 2006 10:34 pm

Post by Munish »

Hi Everybody,
I tried this

Stage:Dummy RowGenerator, 0 record >>>
OCI:Upsert Mode = User Defined Update Only

I have written my own script to update one Column.
Script:
UPDATE
EDX_RPT_ACCOUNT_FACT
SET
CUST_VIEW_FLAG = 'N'
WHERE
CUST_VIEW_FLAG = 'Y'

This script works fine in Toad but no row is updated.

WHat is that I am missing ?

Thanks and regards,
Munish
MK
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Munish wrote:This script works fine in Toad but no row is updated.
Would you like to clarify that statement? How can it "work fine" if an UPDATE statement updates no rows? Answer: if there are no rows that match the WHERE condition. In that case, DataStage would achieve the same "result".

What is the Generator property in the Row Generator stage? Do make sure that you generate one row.
Last edited by ray.wurlod on Thu Feb 15, 2007 2:13 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Munish wrote:I have written my own script to update one Column.
Script:
UPDATE
EDX_RPT_ACCOUNT_FACT
SET
CUST_VIEW_FLAG = 'N'
WHERE
CUST_VIEW_FLAG = 'Y'

This script works fine in Toad but no row is updated.

WHat is that I am missing ?
Auto commit could be disabled in TOAD. Do an explicit commit and check if the rows get updated.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
Munish
Participant
Posts: 89
Joined: Sun Nov 19, 2006 10:34 pm

Post by Munish »

Thanks Everyone,
It worked fine this time.

I was missing:
I was not passing any record from Row Generator.
We have to make sure that it should be atleast 1.

Thanks again,
Closing the thread,

Regards,
Munish
MK
Post Reply