Sequence on a char(6) column

From: "Roland Giesler" <roland(at)giesler(dot)za(dot)net>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Sequence on a char(6) column
Date: 2005-12-14 14:23:14
Message-ID: TAXNET017G1TMe7Xn4U000000bb@frontdoor.taxpoint.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Is it possible to create a sequence like 'ABC012','ABC013', etc. in a
char(6) column?

I'm toying with some ideas...

I actually need to generate random 6 digit membership number in the format
'CCCNNN' (where C is a character A-Z and D a digit 0-9). The idea is to
have a number like a South African motorvehicle registration (also used
elsewhere) in the format XYZ123. For security reasons a member number like
this should be random and I'm wondering if anybody has done something like
this in a pl/pgsql. I guess a procedure like this could be used as a
default for a column, and making the column unique could prevent duplicates,
although this should ideally be done as part of the generating procedure,
not afterwards.

A sample, or pointers would all be appreciated.

Thanks

Roland

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jaime Casanova 2005-12-14 14:26:47 Re: Sequence on a char(6) column
Previous Message Charles Bai 2005-12-14 13:30:38 Re: VB.Net with PostgreSQL