I am trying to import an excel spreadsheet into Oracle using Toad. The gotcha is that the table I am importing into has a primary key field that I use a “sequence”.nextval to populate in a normal stored procedure insert.
Using the Toad import wizard, I tried putting in ‘table_seq.nextval’ as an expression but when I execute the wizard at the end I get the error: Could not convert variant of type (UnicodeString) into type (Double).
So is it possible to import Excel data using sequence.nextval with the Toad import wizard or is there a better way?
I also gave some thought to just letting Excel generate the key by starting the seed beyond what is currently in the table. But being new to Oracle, would this mess-up the sequence I have setup for the table? For example, if before the insert, the next available ID is say 500 and the inserts from Excel inserted rows from 500 to 5000, would the next execution of a stored procedure for that table’s sequence try to use 500?
Thanks in advance!
Yes, the sequence will remain at 50, and you’ll get
primary key violatedexception when using stored procedure.That’s because sequences are not linked to tables in any way. And cannot be linked. They are separated objects.
The best approach I see is to use a trigger
on insert for each rowwhich will set the id tonextval.Code example: