Re: Generating unique values for TEXT columns - Mailing list pgsql-general

From Joost Kraaijeveld
Subject Re: Generating unique values for TEXT columns
Date
Msg-id A3D1526C98B7C1409A687E0943EAC41048A072@obelix.askesis.nl
Whole thread Raw
In response to Generating unique values for TEXT columns  ("Frank D. Engel, Jr." <fde101@fjrhome.net>)
List pgsql-general
Hi Frank

I use the following constructs to generate an objectid's in my database:

CREATE SEQUENCE public.tsfraction MAXVALUE 999999;

CREATE FUNCTION getobjectid() RETURNS text
AS '
    select((select(to_char(current_timestamp, \'yyyy-mm-dd-hh-mm-ss\'))) ||
(select(to_char((nextval(\'tsfraction\')),\'-FM000000MI\'))))as return; 
'
LANGUAGE 'sql';

CREATE TABLE public.object
(
    objectid text NOT NULL DEFAULT getobjectid(),
    -- other columns omited
    CONSTRAINT pk_object PRIMARY KEY (objectid)
) WITH OIDS;



Groeten,

Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
e-mail: J.Kraaijeveld@Askesis.nl
web: www.askesis.nl

pgsql-general by date:

Previous
From: "Frank D. Engel, Jr."
Date:
Subject: Generating unique values for TEXT columns
Next
From: Josué Maldonado
Date:
Subject: Re: Generating unique values for TEXT columns