I'm trying to find out if there is any way to generate GUIDs
in DB2. I've read the FAQ and have gone a bunch of googling
both against this newsgroup and the web in general.
I have found out about GENERATE_UNIQUE, but from my reading
of the documentation, that does not generate a true GUID.
Is there any way to do it in "pure" DB2? If not, is there
any way to make DB2 do an OS-level call (like to the Win2K/etc.
function that generates GUIDs, or something similar on
other OSes) to get one?
Thanks.
--
Rich Carreiro rlc...@animato.arlington.ma.us
"Home is where you hang your hat." "Character is what you are in the dark."
On Mon, 11 Nov 2002 23:07:04 UTC, Rich Carreiro
<rlc...@animato.arlington.ma.us> wrote:
> Hello.
>
> I'm trying to find out if there is any way to generate GUIDs
> in DB2. I've read the FAQ and have gone a bunch of googling
> both against this newsgroup and the web in general.
>
> I have found out about GENERATE_UNIQUE, but from my reading
> of the documentation, that does not generate a true GUID.
>
> Is there any way to do it in "pure" DB2? If not, is there
> any way to make DB2 do an OS-level call (like to the Win2K/etc.
> function that generates GUIDs, or something similar on
> other OSes) to get one?
>
> Thanks.
>
--
Lorne Sunley
When defining the UDF to DB2, don't forget to specify that it is NOT
DETERMINISTIC, or your GUID will not be globally unique.
- Mark Yudkin
"Rich Carreiro" <rlc...@animato.arlington.ma.us> wrote in message
news:m3bs4vk...@animato.animato.arlington.ma.us...
Cheers
Serge
--
Serge Rielau
DB2 UDB SQL Compiler Development
IBM Software Lab, Toronto
Visit DB2 Developer Domain at
http://www7b.software.ibm.com/dmdd/
One of the approaches for distinct ranges allocation is deshcribed in
detail in 2nd chapter of this:
http://www7b.boulder.ibm.com/dmdd/library/techarticle/0209kuznetsov/0209kuznetsov.html
> Hello.
>
> I'm trying to find out if there is any way to generate GUIDs
> in DB2. I've read the FAQ and have gone a bunch of googling
> both against this newsgroup and the web in general.
>
> I have found out about GENERATE_UNIQUE, but from my reading
> of the documentation, that does not generate a true GUID.
>
> Is there any way to do it in "pure" DB2? If not, is there
> any way to make DB2 do an OS-level call (like to the Win2K/etc.
> function that generates GUIDs, or something similar on
> other OSes) to get one?
>
> Thanks.
Just some thoughts:
rtrim(char(current server)) || ':' || char(current timestamp)
rtrim(char(current server)) || ':' || generate_unique()
if current server isnt unique enough, you could perhaps store the servers
ip in a table, and select from there. For example:
select ipnumber || ':' || generate_unique() from system_settings