... there is even a 4th option (except using a trigger).
... using the SQL scalar function GENERATE_UNIQUE
Generate_Unique() returns a 13 Byte Character value for bit data and does
not only include the timestamp, but generates also unique values if several
records are changed or written in the same micro second. The scalar function
TIMESTAMP will return the timestamp stored in the GENERATE_UNIQUE() value
Example:
Create Table MySchema/Mytable
(MyInt Integer,
MyUnique Char(13) for Bit Data);
Insert into MyTable
Select RRN(a), Generate_Unique()
From OtherTable a;;
Select a.*, Timestamp(MyUnique)
from Mytable a;
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von Stone, Joel
Gesendet: Tuesday, 01.5 2012 20:34
An: 'Midrange Systems Technical Discussion'
Betreff: RE: Unique ID
And option 4 is ??
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of rob@xxxxxxxxx
Sent: Tuesday, May 01, 2012 11:44 AM
To: Midrange Systems Technical Discussion
Subject: Re: Unique ID
I suggest one of four options:
1 - Using an identity column. See GENERATED at
http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/topic/db2/rbafzhctab
l.htm
2 - Using a 'sequence'.
http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/topic/db2/rbafzcsequ
ence.htm
3 - Using a UUID.
http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/topic/rzatk/GENUUID.
htm
Rob Berendt
As an Amazon Associate we earn from qualifying purchases.