• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

sequence in oracle

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic