Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Getting currval from a sequence with out incrementing nextval

Re: Getting currval from a sequence with out incrementing nextval

From: <Martin.Choma_at_gmail.com>
Date: 3 Mar 2006 16:06:49 -0800
Message-ID: <1141430809.386556.89200@i40g2000cwc.googlegroups.com>


Current value of sequence you can obtain in this way:

DECLARE
  curr_val NUMBER;
BEGIN
  SELECT my_seq.CURRVAL

       INTO curr_val
     FROM DUAL;

END; be carefull, if SELECT MY_SEQ.NEXTVAL FROM DUAL; has never been perfomed before you will get this error: ORA-08002: sequence MY_SEQ.CURRVAL is not yet defined in this session

But i would prefer to leave checking of unique constraint on Oracle. What if your check on id 100 passed, but after that moment someone insert 100 too, and you than insert 100 again.

Martin Received on Fri Mar 03 2006 - 18:06:49 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US