I am fetching some data from an Oracle table and inserting into a Netezza table using an SSIS Script Task in Control Flow.
Objective: to populate a surrogate key (like a Landing ID) field in the destination table.
For now the query looks like:
insert into destination_table
(
id, col1, col2, col3
)
select (SELECT NEXT VALUE FOR MY_SEQUENCER), field1, field2, field3
from source_table
I am using a Netezza sequence (MY_SEQUENCER) to generate a unique number but the sequence value doesn't get incremented until the query commits. As a result, after the data is inserted, I am getting:
1, val1, val2, val3
1, val4, val5, val6
...
subsequent run:
2, val1, val2, val3
2, val4, val5, val6
...
and so on.
Is there a way to achieve this without using a sequence?
Thanks a lot for reading and any ideas/tips/suggestions you may provide.