Re: custom serial number

Поиск
Список
Период
Сортировка
От Gerardo Herzig
Тема Re: custom serial number
Дата
Msg-id 492306CD.9040007@fmed.uba.ar
обсуждение исходный текст
Ответ на Re: custom serial number  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Список pgsql-sql
A. Kretschmer wrote:
> am  Tue, dem 18.11.2008, um  1:09:44 -0800 mailte mahmoud ewiwi folgendes:
>> hi gurus
>> i have a problem in generating serial number with the form yyyymm0000 how can i do that?
> 
> test=# create temporary sequence foo;
> CREATE SEQUENCE
> test=# select to_char(current_date,
> 'yyyymm')||trim(to_char(nextval('foo'),'09999'));
>   ?column?
> -------------
>  20081100001
> (1 row)
> 
Thats nice. You should now take care about changing months.
I guess a cron job can do the job restarting the sequence the first day
of the month. (If we are talking about Unix/Linux, off course)

Gerardo


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Pavel Stehule"
Дата:
Сообщение: Re: custom serial number
Следующее
От: "Ryan Wells"
Дата:
Сообщение: Left Join Question