How to create GUID in Windows format in Postgres 9.0+?
I tried function
CREATE or REPLACE FUNCTION public.getguid() RETURNS varchar AS $BODY$
DECLARE
v_seed_value varchar(32);
BEGIN
select
md5(
inet_client_addr()::varchar ||
timeofday() ||
inet_server_addr()::varchar ||
to_hex(inet_client_port())
)
into v_seed_value;
return (substr(v_seed_value,1,8) || '-' ||
substr(v_seed_value,9,4) || '-' ||
substr(v_seed_value,13,4) || '-' ||
substr(v_seed_value,17,4) || '-' ||
substr(v_seed_value,21,12));
END; $BODY$ LANGUAGE 'plpgsql' VOLATILE SECURITY DEFINER;
from
http://postgresql.1045698.n5.nabble.com/newid-in-postgres-td1879346.html
Tried
select getguid()
union all
select getguid()
but it returns same values
"c41121ed-b6fb-c9a6-bc9b-574c82929e7e"
"c41121ed-b6fb-c9a6-bc9b-574c82929e7e"
How to fix this so that unique rows are returned?