GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL Plus
Go To First  |  Previous Question  |  Next Question 
 SQL Plus  |  Question 27 of 132    Print  
How to access the current value and next value from a sequence

  
Total Answers and Comments: 3 Last Update: December 07, 2006   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 27, 2005 03:52:11   #1  
kumar vikal        

RE: How to access the current value and next value from a sequence
for current value the function is :- sequence_name.currval
and for the next value it is sequence_name.nextval

 
Is this answer useful? Yes | No
September 20, 2005 07:11:25   #2  
kishorebabukm Member Since: September 2005   Contribution: 1    

RE: How to access the current value and next value fro...

I would like to give you a small example to use the sequence.currval and sequence.nextval

create sequence seq_name

start with 1

minvalue 1

maxvalue 999

increment by 1

nocycle

insert into table_name (sno name) values (seqname.nextval 'abc');

select seqname.currval from dual


 
Is this answer useful? Yes | No
December 07, 2006 08:10:26   #3  
rampratap409 Member Since: September 2006   Contribution: 111    

RE: How to access the current value and next value fro...

select <sequencename>.nextval from dual;

select <sequencename>.currval from dual;

or

select * from user_sequences where sequence_name <sequencename>;

here last_number is your currval and last_number + increment_by is your nextval


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape