Home » Infrastructure » Windows » Returning next ID Value?
Returning next ID Value? [message #101085] Fri, 23 April 2004 04:32 Go to next message
Andrew
Messages: 144
Registered: March 1999
Senior Member
Hi,

I'm using the following code to get the next table ID from a sequence: -

strSQL = "SELECT SEQ_TB_CUSTOMERS.NEXTVAL FROM DUAL"
            
Set objOraDynaset = m_OraDatabase.createdynaset(strSQL, 0&)
            
lngID = objOraDynaset.fields(0).Value

The above works but the next ID isn't sequential, I'm getting e.g. 216, 218, 220, 222, 224 etc.

Any idea why this could be?

Regards
Re: Returning next ID Value? [message #101161 is a reply to message #101085] Sat, 29 May 2004 04:30 Go to previous message
Tak Tang
Messages: 142
Registered: May 2004
Senior Member
If you are running this twice in a row without shutting down the database, then it is because your sequence is setup to increment by 2.

If this is occurring between database restarts, then it is because the sequence is set to 'cache 2'.

http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_615a.htm#2067095

Takmeister
Previous Topic: Urgent
Next Topic: TNS error
Goto Forum:
  


Current Time: Fri Apr 26 06:32:18 CDT 2024