Surrogate key using Oracle sequence

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
snt_ds
Premium Member
Premium Member
Posts: 280
Joined: Wed Oct 18, 2006 11:53 am
Location: Pune, India

Surrogate key using Oracle sequence

Post by snt_ds »

Hi,

OCI --> TRN --> OCI

I have a design where I read from an Oracle table (Stg) and load in the another Oracle table with a Transformer in between. The only thing this job does is to load the tgt Oracle table with a Surrogate key from an Oracle sequence.
I am using the SeqName.NextVal as part of the insert statement itself, but it keeps failing and the log says.
"ORA-01036: illegal variable name/number"

The User defined SQL for inserts is as below.

INSERT INTO TABLE (TREASURY_PRODUCT_CODE,SOURCE_PRODUCT,SOURCE_PRODUCT_TYPE,SOURCE_PRODUCT_SUB_TYPE,CREATED_BY,CREATED_ON,UPDATED_BY,UPDATED_ON) VALUES (Schemaname.SEQNAME.NEXTVAL,:2,:3,:4,:5,TO_DATE(:6, 'YYYY-MM-DD HH24:MI:SS'),:7,TO_DATE(:8, 'YYYY-MM-DD HH24:MI:SS'))

The sequence is created correctly in the DB.

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

Post by chulett »

For every column defined on the Columns tab, you need to specify a numbered bind variable. You've got 8 columns defined but only 7 mentioned in the sql, hence the error.

Remove the target for the sequence from the column list (TREASURY_PRODUCT_CODE) and decrement all of your bind variable numbers by 1.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sachin1
Participant
Posts: 325
Joined: Wed May 30, 2007 7:42 am
Location: india

Re: Surrogate key using Oracle sequence

Post by sachin1 »

hello dear please remove your column name for which you want to use a sequencer from column tab but in your user-defined sql statement do mention column name and its sequencer with proper order.
snt_ds
Premium Member
Premium Member
Posts: 280
Joined: Wed Oct 18, 2006 11:53 am
Location: Pune, India

Post by snt_ds »

Thanks for the prompt responses..it worked.
Post Reply