Re: [URGENT] How to generata a unique string id - Mailing list pgsql-general

From Richard Huxton
Subject Re: [URGENT] How to generata a unique string id
Date
Msg-id 006401c0e547$499f76c0$1001a8c0@archonet.com
Whole thread Raw
In response to [URGENT] How to generata a unique string id  (Manuel Durán Aguete <mdaguete@alsernet.es>)
List pgsql-general
From: "Manuel Durán Aguete" <mdaguete@alsernet.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


pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Bitwise operators in SQL
Next
From: "Eric G. Miller"
Date:
Subject: Re: Trouble with strange OUTER JOIN syntax