How can we execute Oracle sequence in Postgres?

310 views Asked by At

In between migration from Oracle to Postgres, I need to execute some insert statement for an Oracle table from Postgres (in which the primary key field is using a sequence for uniqueness).

Now at the time of the migration I am converting some procedure that is used to insert a row in a table, but I can't move table directly from oracle to Postgres due to a higher dependency on the table.

That's why I need to execute an Oracle sequence from Postgres.

1

There are 1 answers

2
Laurenz Albe On

The simplest solution is probably to create a view in Oracle that doesn't contain the column that is to be filled from the sequence.

Then define a trigger on the table that fills the column from the sequence when NULL and creare a foreign table on the view.

Wheb you INSERT into the foreign table, the column will get filled by the trigger.