Click to See Complete Forum and Search --> : SEQUENCE FOR VALUES IN INSERT CLAUSE


Sureshy
08-14-2001, 06:16 AM
Hi,

Can anyone please give me the syntax for using a sequence in the values clause of an insert statement :

e.g
insert into table1(id)
values (select seq.nextval from sys.dual)

the above is not correct syntax.

Thanks

Suresh

dknight
08-14-2001, 06:21 AM
Try:

insert into EMP values (emp_seq.nextval, ....);

commit;

I have read on this board that selecting the next sequence value from dual can leave open cursors.

Good luck.

chrisrlong
08-15-2001, 12:40 PM
Actually, try:

insert into table1(id)
select seq.nextval from sys.dual;


- Chris

Sureshy
08-16-2001, 10:33 AM
Thanks guys,

Both solutions worked.