Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Avoiding sequence getting the nextval in case of error

user545194Dec 9 2021

Hi,
Is the nextval being fetched from the sequence even in the event of an error?
DECLARE
v_description VARCHAR2(45);
BEGIN ...
SELECT description FROM table1
WHERE description = v_description
IF v_description <> 'Some value' THEN
raise_application_error(-20001, 'Value not found!');
ELSE
INSERT INTO table2 (
id,
description
) VALUES (
new_id_seq.NEXTVAL,
v_description
);
END IF;
...
EXCEPTION
WHEN OTHERS THEN
log_error();
END;
/
BTW: Code tags? {code}

This post has been answered by BluShadow on Dec 10 2021
Jump to Answer
Comments
Post Details
Added on Dec 9 2021
11 comments
1,396 views