Search code examples
oracleoracle11gssisssis-2012script-component

Problems inserting data into Oracle table with sequence column via SSIS


I am doing data insert into a table in Oracle which is having a sequence set to it in one of the columns say Id column. I would like to know how to do data loads into such tables.

I followed the below link -

It's possible to use OleDbConnections with the Script Component?

and tried to create a function to get the .nextval from the Oracle table but I am getting the following error -

Error while trying to retrieve text for error ORA-01019

I realized that manually setting the value via the package i.e. by using the Script task to enumerate the values but is not incrementing the sequence and that is causing the problem. How do we deal with it? Any links that can help me solve it?

I am using SSIS-2014 but I am not able to tag it as I don't due to paucity of reputation points.


Solution

  • I created a workaround to cater to this problem. I have created staging tables of the destination without the column that takes the Sequence Id. After the data gets inserted, I am then calling SQL statement to get the data into the main tables from staging table and using the .nextval function. Finally truncating/dropping the table depending on the need. It would still be interesting to know how this same thing can be handled via script rather having this workaround.

    For instance something like below -

    insert into table_main
    select table_main_sequence_name.nextval
    ,*
    from (
    select *
    from table_stg
    )