Reputation: 4827
Is this the best way to handle this insert, such that columns test1 and test2 are always equal?
CREATE SEQUENCE seq_temp
START WITH 1
INCREMENT BY 1
CACHE 50
NOCYCLE;
CREATE TABLE test_tbl (
test1 NUMBER,
test2 NUMBER
);
INSERT INTO test_tbl
SELECT
seq_temp.nextval,
seq_temp.currval
FROM dual;
Upvotes: 0
Views: 492
Reputation: 60262
It makes no difference - you must use nextval for at least one column, but for the other column nextval and currval will be the same value.
In other words, all the following statements will have the same effect:
SELECT seq_temp.nextval, seq_temp.currval FROM dual;
SELECT seq_temp.nextval, seq_temp.nextval FROM dual;
SELECT seq_temp.currval, seq_temp.nextval FROM dual;
Upvotes: 1