pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedhow to use nextval()
3+ messages / 3 participants
[nested] [flat]
* how to use nextval()
@ 2002-07-05 12:03 juerg.rietmann@pup.ch
2002-07-05 12:28 ` Re: how to use nextval() Stephane Schildknecht <sschildknecht@aurora-linux.com>
2002-07-05 12:37 ` Re: how to use nextval() Achilleus Mantzios <achill@matrix.gatewaynet.com>
0 siblings, 2 replies; 3+ messages in thread
From: juerg.rietmann@pup.ch @ 2002-07-05 12:03 UTC (permalink / raw)
To: pgsql-sql
Hello there
I have an idea how to solve my problem on copy a record to a new one in the
same table. To do so I need the next value for the primary key.
Using :
select nextval('pk_auftrag') as nextkey from auftrag;
I get an error like : Relation pk_auftrag does not exist !
Thanks for any help ... jr
__________________________________________________
PFISTER + PARTNER, SYSTEM - ENGINEERING AG
Juerg Rietmann
Grundstrasse 22a
6343 Rotkreuz
Switzerland
internet : www.pup.ch
phone : +4141 790 4040
fax : +4141 790 2545
mobile : +4179 211 0315
__________________________________________________
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: how to use nextval()
2002-07-05 12:03 how to use nextval() juerg.rietmann@pup.ch
@ 2002-07-05 12:28 ` Stephane Schildknecht <sschildknecht@aurora-linux.com>
1 sibling, 0 replies; 3+ messages in thread
From: Stephane Schildknecht @ 2002-07-05 12:28 UTC (permalink / raw)
To: juerg.rietmann@pup.ch; +Cc: pgsql-sql
Le ven 05/07/2002 à 14:03, juerg.rietmann@pup.ch a écrit :
> Hello there
>
> I have an idea how to solve my problem on copy a record to a new one in the
> same table. To do so I need the next value for the primary key.
>
> Using :
>
> select nextval('pk_auftrag') as nextkey from auftrag;
>
> I get an error like : Relation pk_auftrag does not exist !
>
> Thanks for any help ... jr
Try to get the right name of the sequence.
By default, something like auftrag_auftrag_id_seq, if auftrag_id is the
serial primary key.
select nextval('auftrag_auftrag_id_seq') as nextkey;
S@S
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: how to use nextval()
2002-07-05 12:03 how to use nextval() juerg.rietmann@pup.ch
@ 2002-07-05 12:37 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
1 sibling, 0 replies; 3+ messages in thread
From: Achilleus Mantzios @ 2002-07-05 12:37 UTC (permalink / raw)
To: juerg.rietmann@pup.ch; +Cc: pgsql-sql
On Fri, 5 Jul 2002 juerg.rietmann@pup.ch wrote:
> Hello there
>
> I have an idea how to solve my problem on copy a record to a new one in the
> same table. To do so I need the next value for the primary key.
>
> Using :
>
> select nextval('pk_auftrag') as nextkey from auftrag;
>
> I get an error like : Relation pk_auftrag does not exist !
Do a \d to find out the name of your sequence.
Most probably it will be named as
"auftrag_<your auftrag table primary key>_seq".
Let it be "auftrag_id_seq".
Your command is
SELECT nextval('"auftrag_id_seq"'::text);
>
> Thanks for any help ... jr
>
> __________________________________________________
>
> PFISTER + PARTNER, SYSTEM - ENGINEERING AG
> Juerg Rietmann
> Grundstrasse 22a
> 6343 Rotkreuz
> Switzerland
>
> internet : www.pup.ch
> phone : +4141 790 4040
> fax : +4141 790 2545
> mobile : +4179 211 0315
> __________________________________________________
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
>
--
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
tel: +30-10-8981112
fax: +30-10-8981877
email: achill@matrix.gatewaynet.com
mantzios@softlab.ece.ntua.gr
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-07-05 12:37 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-07-05 12:03 how to use nextval() juerg.rietmann@pup.ch
2002-07-05 12:28 ` Stephane Schildknecht <sschildknecht@aurora-linux.com>
2002-07-05 12:37 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox