Get the next sequence for insert-key generation. The result is stored in the variable dbobj%lastseq.
Please note that not all database platforms support automatic key generation. For those that do, the implementation may be very different.
Some database platforms generate a new key value implicitly whenever a record is inserted, and allow you to the generated key without affecting its value (like MySQL).
Some others only allow you to get the key value from a sequence name (the seq argument) and a new value is generated every time it was accessed (like mSQL). The sequence name is usually the table name (but does not have to be). Therefore, the table name in dbobj%table is the default seq.
(Please note that accessing to the variable dbobj%lastseq will not cause a key generation as the variable is only a buffer holding the sequence returned by the action "nextseq".)
The behaviour of "nextseq" is platform dependent and it is dangerous to use it in the insert statement as two processes may get the same value if the platform does not generate a new key every time it was accessed. It is recommended to insert via the "insert" action, instead of an explicit SQL insert statement via the "query" parameter, unless you know exactly what you're doing and have the need to do so. |