wood burning stoves 2.0*
The moose likes Oracle/OAS and the fly likes sequence in oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "sequence in oracle" Watch "sequence in oracle" New topic
Author

sequence in oracle

siva sankar
Ranch Hand

Joined: Jul 13, 2006
Posts: 68
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

Joined: Mar 17, 2006
Posts: 44
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....


"What's in a name? That which we call a rose by any other name would smell just as sweet."<br />(William Shakespeare, Romeo and Juliet, Act II, Scene II)
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
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 ]
 
wood burning stoves
 
subject: sequence in oracle