Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Insert using a sequence in a nested query in Oracle Database
CREATE SEQUENCE cid_seq
START WITH 100
INCREMENT BY 1;
CREATE OR REPLACE FUNCTION get_next_cseq
RETURN NUMBER AS l_return NUMBER;
BEGIN
SELECT cid_seq.NEXTVAL INTO l_return FROM DUAL;
RETURN l_return;
END;
/
INSERT INTO
orphans
(
SELECT
get_next_cseq() AS customer_id,
name
FROM
(
SELECT
...
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.