Re: [URGENT] How to generata a unique string id

From: "Richard Huxton" <dev(at)archonet(dot)com>
To: Manuel Durán Aguete <mdaguete(at)alsernet(dot)es>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: [URGENT] How to generata a unique string id
Date: 2001-05-25 17:31:07
Message-ID: 006401c0e547$499f76c0$1001a8c0@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

From: "Manuel Durán Aguete" <mdaguete(at)alsernet(dot)es>

> I need to generate a unique four letters string (p.e
> AAAA,AAAB) for any tuple I insert into a table, any idea ? How can I do
> this ?

Create a sequence foo_seq and then set your field

create table example (
id default myfunc(nextval(foo_seq)),
a text,
b int4
);

Define myfunc to convert the integer into a character string (take the value
mod 26, append to string, divide value by 26, repeat)

- Richard Huxton

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2001-05-25 18:12:22 Re: Bitwise operators in SQL
Previous Message The Hermit Hacker 2001-05-25 17:09:48 PostgreSQL v7.1.2 Now Available ...