Thread: Question

Question

From
aymen marouani
Date:
<div dir="ltr"><span class="Apple-style-span" style="border-collapse: collapse; ">Hi for all, <br />What is the
possiblesources of the SQLState 55000 "OBJECT NOT IN PREREQUISITE STATE" ? <br />The error 55000 was triggered when I
executedthe following query :<br /> "select currval('"BatchTreatment_batch_treatment_id_seq"');" <br /><br />Thanks in
advance. <br/><br />Cordially.</span></div> 

Re: Question

From
Rob Sargent
Date:
Call nextval first?

Too many quotes?

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"');" 
>
> Thanks in advance. 
>
> Cordially.


Re: Question

From
"Ross J. Reedstrom"
Date:
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