Re: custom serial number

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: custom serial number
Date: 2008-11-18 09:26:52
Message-ID: 20081118092652.GB19076@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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)

test=# select to_char(current_date,
'yyyymm')||trim(to_char(nextval('foo'),'09999'));
?column?
-------------
20081100002
(1 row)

test=# select to_char(current_date,
'yyyymm')||trim(to_char(nextval('foo'),'09999'));
?column?
-------------
20081100003
(1 row)

HTH, Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Pavel Stehule 2008-11-18 09:37:23 Re: custom serial number
Previous Message mahmoud ewiwi 2008-11-18 09:09:44 custom serial number