Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > Oracle Sequences...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-14-07, 13:11
versoft versoft is offline
Registered User
 
Join Date: Dec 2003
Location: USA
Posts: 33
Oracle Sequences...

Hi Friends,

Thanks all for the last solution.

How do i get the last sequence number without calling the nextval.

When i call currval without calling the nextval i get the following error...

Code:
select LOSS_EVT_ID_SEQ.CURRVAL from dual ORA-08002: sequence LOSS_EVT_ID_SEQ.CURRVAL is not yet defined in this session

Is there any way to fetch last sequence number?

Thanks in advance,
Amit
__________________
A friend in need is a friend in deed
Reply With Quote
  #2 (permalink)  
Old 05-14-07, 14:21
chuck_forbes chuck_forbes is online now
Registered User
 
Join Date: Dec 2003
Posts: 847
If the sequence number is that meaningful, then you need to come up with another approach for your primary key. The last sequence number available, may not be the last sequence number used. Sequence values are regularly purged from memory during normal database use, and so you'll see gaps. Also, if someone grabs the nextval, but then rolls back their transaction, the sequence number is not rolled back.

---=Chuck
Reply With Quote
  #3 (permalink)  
Old 04-06-08, 04:16
Sugam Khetrapal Sugam Khetrapal is offline
Registered User
 
Join Date: Apr 2008
Posts: 6
Can someone please tell me what is the escape sequence for ' ?
I need to retrieve a number from a query, but the query will fetch the number only if it in enclosed in '0123423' i.e. single inverted comma
Reply With Quote
  #4 (permalink)  
Old 04-07-08, 04:13
flyboy flyboy is offline
Registered User
 
Join Date: Mar 2007
Posts: 114
> Is there any way to fetch last sequence number?

Yes, but only in case it was generated before by NEXTVAL in the current transaction.

Documentation links:
Sequence pseudocolumns:
Quote:
Before you use CURRVAL for a sequence in your session, you must first initialize the sequence with NEXTVAL.
CREATE SEQUENCE Command:
Quote:
When a sequence number is generated, the sequence is incremented, independent of the transaction committing or rolling back. If two users concurrently increment the same sequence, then the sequence numbers each user acquires may have gaps, because sequence numbers are being generated by the other user. One user can never acquire the sequence number generated by another user. After a sequence value is generated by one user, that user can continue to access that value regardless of whether the sequence is incremented by another user.
By the way, how would you define "last sequence number" in multi-user environment? You may implement it yourself, but then you need to serialize requests for the values.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On