Sequence on a char(6) column - Mailing list pgsql-novice

From Roland Giesler
Subject Sequence on a char(6) column
Date
Msg-id TAXNET017G1TMe7Xn4U000000bb@frontdoor.taxpoint.co.za
Whole thread Raw
Responses Re: Sequence on a char(6) column
Re: Sequence on a char(6) column
List 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



pgsql-novice by date:

Previous
From: Charles Bai
Date:
Subject: Re: VB.Net with PostgreSQL
Next
From: Jaime Casanova
Date:
Subject: Re: Sequence on a char(6) column