How to write Pre SQL in ODBC stage

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
palak08
Participant
Posts: 75
Joined: Thu Nov 04, 2010 5:54 pm

How to write Pre SQL in ODBC stage

Post by palak08 »

Hi All,

I am using Datastage with Netezza combination. To connect to netezza, I am using ODBC connection. When I use ODBC stage, I can not see "Pre and Post SQL" options.

Is there a way to use this feature?

Thanks in Advance for help.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I don't believe the Server ODBC stage supports that... the ODBC Connector and Enterprise stages do, however. What do you need to do before/after sql?
-craig

"You can never have too many knives" -- Logan Nine Fingers
palak08
Participant
Posts: 75
Joined: Thu Nov 04, 2010 5:54 pm

Post by palak08 »

Thanks Craig for your reply.
I am trying to delete records from target table on certain condition.

Step 1: Delete from table where Col1='ABC'
Step 2: Insert into Target_Table.

Please let me know if there are any workarounds other than writing a Stored Procedure :-)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Two links to the ODBC stage, ordered properly, with the delete link being sent first. Constrain the delete link to only send the first row to the target, for example using @OUTROWNUM=1.
Last edited by chulett on Thu Sep 15, 2011 7:50 am, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Tip: Connectors are available in server jobs as well as in parallel jobs.
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 »

I thought Connectors were PX only... or at least initially. When did they come over to the Server side? However, I did see in the 8.5 documentation that basically every stage other than the Connectors are listed as 'deprecated'.
-craig

"You can never have too many knives" -- Logan Nine Fingers
palak08
Participant
Posts: 75
Joined: Thu Nov 04, 2010 5:54 pm

Post by palak08 »

Thanks Craig.. It worked.

The only problem is, I am loosing one record. If I use @OUTROWNUM=1 then that record is sent to the delete link and thus not get inserted into target table.

For Now- I am storing that one record in Seq file and inserting back into target.

Is there a better way to handle that one record as well?
Is there a way to change output execution order?

Thanks.
Last edited by palak08 on Thu Sep 15, 2011 10:37 am, edited 2 times in total.
palak08
Participant
Posts: 75
Joined: Thu Nov 04, 2010 5:54 pm

Post by palak08 »

Hey Ray,

I did not find ODBC connector in Datastage 8.1. Is this a new stage introduced in 8.5?

Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You shouldn't be losing anything, that constraint should only be on the delete link and there shouldn't be any constraint on the normal loading link. Records don't have to go down one link or the other, they can go down any number of links.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes, availability began in 8.5.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply