Generate Sequence in Oracle DB in PX jobs.
Posted: Thu Mar 09, 2006 11:12 am
Hi,
I am using a parallel job to generate a sequence in Oracle.
Every record will have that unique number.
I am using a LookUp stage to achieve this. heres how my job looks like:
Primary source _______ Lookup Stage _______Output File (ID, Val1,...)
(Sequential File) ^
(Key,Val1) Reference Link |
Oracle Sparse Lookup
(Key, ID )
NOTE: I have given same names (meta data) for Key in primary source as well as Oracle Sparse Lookup.
Here is the query i m using in Oracle Sparse Lookup.
SELECT ID_SEQUENCE.NEXTVAL Id
FROM DUAL
where 1=ORCHESTRATE.Key
where Key(ORCHESTRATE.Key) is the Key Defined on Primary source.
It is nothing but a constant 1 in all the records.
in the above case, i am getting a failed lookup, and the value of ID is Null in all the lookups.
So i tried creating a temporary table (Key varchar(1), ID NUMBER) in Oracle for testing purpose
and this query works fine, in Oracle Sparse lookup.
SELECT ID
FROM TEMP_TABLE
WHERE Key=ORCHESTRATE.Key
I guess the problem is the Dual table dont have a column by name "1".
But Similar kind of query is working for me In DataStage Server Lookup,
with slight difference as follows:
SELECT 1, ID_SEQUENCE.NEXTVAL Id FROM DUAL
where 1=:1
But my requirement is a Parallel Job. If i dont get it to work, i guess i can go for a join, but i dont want to really do a join for simply generating Sequences. Also i cant use Surrogate Key generator, as this sequences have to be from Oracle Server, and many users acess this sequence in parallel.
Thanks in advance, and excuse me for this lengthy description.
Warm Regards,
Kash.
I am using a parallel job to generate a sequence in Oracle.
Every record will have that unique number.
I am using a LookUp stage to achieve this. heres how my job looks like:
Primary source _______ Lookup Stage _______Output File (ID, Val1,...)
(Sequential File) ^
(Key,Val1) Reference Link |
Oracle Sparse Lookup
(Key, ID )
NOTE: I have given same names (meta data) for Key in primary source as well as Oracle Sparse Lookup.
Here is the query i m using in Oracle Sparse Lookup.
SELECT ID_SEQUENCE.NEXTVAL Id
FROM DUAL
where 1=ORCHESTRATE.Key
where Key(ORCHESTRATE.Key) is the Key Defined on Primary source.
It is nothing but a constant 1 in all the records.
in the above case, i am getting a failed lookup, and the value of ID is Null in all the lookups.
So i tried creating a temporary table (Key varchar(1), ID NUMBER) in Oracle for testing purpose
and this query works fine, in Oracle Sparse lookup.
SELECT ID
FROM TEMP_TABLE
WHERE Key=ORCHESTRATE.Key
I guess the problem is the Dual table dont have a column by name "1".
But Similar kind of query is working for me In DataStage Server Lookup,
with slight difference as follows:
SELECT 1, ID_SEQUENCE.NEXTVAL Id FROM DUAL
where 1=:1
But my requirement is a Parallel Job. If i dont get it to work, i guess i can go for a join, but i dont want to really do a join for simply generating Sequences. Also i cant use Surrogate Key generator, as this sequences have to be from Oracle Server, and many users acess this sequence in parallel.
Thanks in advance, and excuse me for this lengthy description.
Warm Regards,
Kash.