Page 1 of 1

Custom - 'Insert else Update' or 'Update else insert'

Posted: Tue Aug 24, 2010 1:17 pm
by raju_chvr
We have a situation in which we have to 'Insert else Update' or 'Update else Insert'.

It works fine at is is for us. In our project the SKEY are the target tables are generated using Oracle Sequencers which have to called in the Insert statements as they are not - called by Triggers.

So, can we make the SQL to be 'Custom SQL' and have both Update and Insert statements one after the other and expect the same Functionality as Upsert or is it that DataStage or Oracle will treat them as separate 2 SQL statements and will execute both of them.

Posted: Tue Aug 24, 2010 4:12 pm
by ray.wurlod
Which one occurs first depends on which option you choose. Obviously you only invoke the sequence in a custom INSERT statement - for an UPDATE statement you must already know the key value.

Posted: Wed Aug 25, 2010 11:23 am
by raju_chvr
Actually my question is - if we use CUSTOM SQL with both Insert and Update statements one after the other, will DataStage and Oracle still treat it as Upsert Statement or not ?

Posted: Wed Aug 25, 2010 1:07 pm
by chulett
I'm actually not sure, never tried it as I tend to avoid those 'combo' actions. Why not give it a shot and let us know?

Posted: Wed Aug 25, 2010 3:07 pm
by raju_chvr
Tried and Tested it. It actually executes both Insert and Update statements one after the other and doesn't do them conditionally ?

Can I use Merge Statement in ORAOCI stage ?

PS: We are on Linux Platform with DataStage 8.1 Server edition connecting to Oracle 10g using OraOci 9i stage..

Posted: Wed Aug 25, 2010 3:16 pm
by anbu
You should be able to use Merge statement