Path: dp-news.maxwell.syr.edu!spool.maxwell.syr.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!postnews.google.com!i40g2000cwc.googlegroups.com!not-for-mail
From: Martin.Choma@gmail.com
Newsgroups: comp.databases.oracle.server
Subject: Re: Getting currval from a sequence with out incrementing nextval
Date: 3 Mar 2006 16:06:49 -0800
Organization: http://groups.google.com
Lines: 20
Message-ID: <1141430809.386556.89200@i40g2000cwc.googlegroups.com>
References: <1141425175.303800.98530@u72g2000cwu.googlegroups.com>
NNTP-Posting-Host: 195.113.65.10
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1141430814 24941 127.0.0.1 (4 Mar 2006 00:06:54 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 4 Mar 2006 00:06:54 +0000 (UTC)
In-Reply-To: <1141425175.303800.98530@u72g2000cwu.googlegroups.com>
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; cs-CZ; rv:1.7.12) Gecko/20050919 Firefox/1.0.7 (ax),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: i40g2000cwc.googlegroups.com; posting-host=195.113.65.10;
   posting-account=5FgfiA0AAACYb07se6GB0rutqZLVb7mw
Xref: dp-news.maxwell.syr.edu comp.databases.oracle.server:262763

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

