sequenc_name.currval not defined

Started by MTover 23 years ago3 messagesgeneral
Jump to latest
#1MT
mt@open2web.com

Hi,

I keep on getting the following error when I attempt to insert a new record:

SELECT * FROM table_name WHERE tableid = currval('tableid_seq');

PostgreSQL said: ERROR: tableid_seq.currval is not yet defined in this
session.

What's weird about this problem is that I have a script that
successfully performs this action.

Thanks for your help,

Mark

#2scott.marlowe
scott.marlowe@ihs.com
In reply to: MT (#1)
Re: sequenc_name.currval not defined

On Thu, 21 Nov 2002, MT wrote:

Hi,

I keep on getting the following error when I attempt to insert a new record:

SELECT * FROM table_name WHERE tableid = currval('tableid_seq');

PostgreSQL said: ERROR: tableid_seq.currval is not yet defined in this
session.

What's weird about this problem is that I have a script that
successfully performs this action.

currval only works during a session when nextval or setval have been run.
It's how it's supposed to work. It's part of the magic of making
sequences transaction safe.

#3Philip Hallstrom
philip@adhesivemedia.com
In reply to: MT (#1)
Re: sequenc_name.currval not defined

you have to call nextval() before you can use currval().

On Thu, 21 Nov 2002, MT wrote:

Show quoted text

Hi,

I keep on getting the following error when I attempt to insert a new record:

SELECT * FROM table_name WHERE tableid = currval('tableid_seq');

PostgreSQL said: ERROR: tableid_seq.currval is not yet defined in this
session.

What's weird about this problem is that I have a script that
successfully performs this action.

Thanks for your help,

Mark

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly