DS and Oracle Sequences

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
__SS__
Participant
Posts: 13
Joined: Mon Dec 01, 2003 10:09 am
Location: Italy, Rome

DS and Oracle Sequences

Post by __SS__ »

Hello

I'm trying to use an oracle sequnce on a ORAOCI9 stage, but i get this fatal:

ORA-01036: illegal variable name/number.

Some can help me?

Ty
__SS__
ogmios
Participant
Posts: 659
Joined: Tue Mar 11, 2003 3:40 pm

Re: DS and Oracle Sequences

Post by ogmios »

__SS__ wrote:Hello

I'm trying to use an oracle sequnce on a ORAOCI9 stage, but i get this fatal:

ORA-01036: illegal variable name/number.

Some can help me?

Ty
__SS__
What are you trying to do, what's the SQL query being executed, ...?

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

Post by chulett »

Define one field in your lookup OCI stage and make sure it is not marked as a key. Call the column anything and put "sequence_name.nextval" in the Derivation column. Choose "Column Generated" as the sql type, click on "Build" and for Table Name put "dual". The stage will write the query for you.

In your transform, simply link the return result from the Lookup to your field needing the Sequence. Note there is no key field to be populated as the query needs nothing in order to select the next value for you.

You could also do it with Custom SQL, but I only use that for things that truly require it. I also avoid the Fully Generated option... bleeh, more trouble than it's worth. :x
-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 »

Are you trying to INSERT or SELECT?

In either case, specify sequencename.NEXTVAL (as indicated earlier)

If it's a SELECT (your ORAOCI stage is extracting rows from Oracle) you can specify it in the derivation column. If it's an INSERT, the easiest way is to write your own SQL, adapting the generated SQL. Remove the column in question from the Columns grid (so that it doesn't generate a parameter marker in the SQL), generate the INSERT statement, then adapt it by including the column name in the columnlist part, and the reference to sequencename.NEXTVAL in the VALUES clause.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
__SS__
Participant
Posts: 13
Joined: Mon Dec 01, 2003 10:09 am
Location: Italy, Rome

Post by __SS__ »

I tried solution by ray.wurlod but i got fatal as in my first post.

About solution by chulett, i have not lookup OCI stage. How can i get it? Have i install any plugin?

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

Post by chulett »

There's no specific 'Lookup' stage in Server like there is in the Mainframe/390 product. Simply use the normal OCI stage, but drag the link from the OCI stage to the Transformer (instead of the other-way-round) to create the Reference Link.

BTW, Ray posted a more thorough explaination for you - I assumed you were trying to get the Sequence via a Lookup. As he noted, you can also embed it inside your insert statement so that Oracle automagically gets and uses it for you - hence the need for custom sql. His way is better as it removes the round-trips to the server for the sequence fetch, but you'll need to do it in a lookup if you want to use it in other parts (dependant tables, for example) later in the same job stream.

And then there's the whole idea of not even using Oracle sequences at all, but that's a story for another day. :D
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply