PL/SQL (MOSC)

MOSC Banner

Sequence numbers (getting duplicate number?)

edited Feb 11, 2020 1:43PM in PL/SQL (MOSC) 9 commentsAnswered

In a package we use a sequence number as the primary key for insert into a table. We can have several sessions hitting this procedure at the same time. On occasion it will get the same sequence number and we get an error that the primary key has been violated on the table where the sequence number is the primary key value. Any suggestions on how to prevent this from happening?

I came up with the below but it is still occurring on occasions.

        SELECT LIMS.SQ_U_ORDER.NEXTVAL INTO v_order FROM DUAL;

        SELECT COUNT (1)
          INTO v_MaxOrderId

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center