Re: Question - Mailing list pgsql-sql

From Ross J. Reedstrom
Subject Re: Question
Date
Msg-id 20090902152821.GC18170@cooker
Whole thread Raw
In response to Question  (aymen marouani <marouani.aymen@gmail.com>)
List pgsql-sql
On Wed, Sep 02, 2009 at 04:28:34PM +0200, aymen marouani wrote:
> Hi for all,
> What is the possible sources of the SQLState 55000 "OBJECT NOT IN
> PREREQUISITE STATE" ?
> The error 55000 was triggered when I executed the following query :
> "select currval('"BatchTreatment_batch_treatment_id_seq"');"

If you execute that (or a similar command) from psql, you'll get a more
human friendly error message:

repository=# select currval('moduleid_seq');
ERROR:  currval of sequence "moduleid_seq" is not yet defined in this
session

Checking the docs at
http://www.postgresql.org/docs/8.3/interactive/functions-sequence.html

currval
   Return the value most recently obtained by nextval for this sequence   in the current session. (An error is reported
ifnextval has never   been called for this sequence in this session.) Notice that because   this is returning a
session-localvalue, it gives a predictable   answer whether or not other sessions have executed nextval since the
currentsession did. 
 

So, that sequence has not had 'nextval' called on it in this session.

Ross
-- 
Ross Reedstrom, Ph.D.                                 reedstrm@rice.edu
Systems Engineer & Admin, Research Scientist        phone: 713-348-6166
The Connexions Project      http://cnx.org            fax: 713-348-3665
Rice University MS-375, Houston, TX 77005
GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E  F888 D3AE 810E 88F0 BEDE



pgsql-sql by date:

Previous
From: Rob Sargent
Date:
Subject: Re: Question
Next
From: "Harun Bolat"
Date:
Subject: Re: PostgreSQL Function: how to know the number of the returned results of the Query