Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sequence in oracle

 
siva sankar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


I created a sequence as following;

create sequence seq1;

Now,i created a table with the following structure.

create table tab1(eno number,ename varchar2(10));

Now,i want the eno in tab1 to refer the sequence seq1.I can't able to get this.Please,suugest me a solution on how i have to do this.

Thanks in Advance,
regards,
Siva Sankar
 
Liju Cherian
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have to use TRIGGERS if you'd like to insert the value automatically, while inserting a new row; else you will have to explicitly fetch the next sequence and insert it along with the other values.

Hope this helps....
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes usually you will have an insert statement that includes getting the nextval from your sequence table.

like

insert into tab1 fields(eno, ename) values (seq1.nextval, "somevalue");

Mark
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use seq1.nextval in the insert

If that's not enough detail, try:

http://www.google.com/search?hl=en&q=oracle+sequence+nextval

dang, mark beat me to it and included the sql!
[ November 08, 2006: Message edited by: Carol Enderlin ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic