Created
January 5, 2011 16:11
-
-
Save igilham/766519 to your computer and use it in GitHub Desktop.
Insert using a sequence in a nested query in Oracle Database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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