From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Ludwig Meyerhoff <ludwig(at)antar(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Sequences - problem |
Date: | 2001-05-05 19:26:46 |
Message-ID: | Pine.BSF.4.21.0105051221540.68775-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> Now, since it is a web-application I am working on, I have several
> Perl-scripts acting on/with the database.
>
> THe informations-program simply has to read out each sequence in order to
> give some statistical data about the database (number of ports, people
> ...)
>
> As I try a
> Pg::doQuery("select currval('portid');", \(at)ports);
> the program gets no reply, on the Postmaster-task (I did not get
> postmaster start on startup/background, runs on a task in foreground) I
> that message:
> ERROR: regionid.currval is not yet defined in this session
> ERROR: jpid.currval is not yet defined in this session
> ERROR: countri.currval is not yet defined in this session
> ERROR: jprid.currval is not yet defined in this session
> ERROR: portid.currval is not yet defined in this session
You cannot call currval on a sequence you have not nextval-ed at least
once in your session. There was a discussion of the a few weeks (I think)
back. currval is defined to give you the value of the sequence most
recently given to your session, not the current/highest value of the
sequence especially since that value may never actually go into a table.
In addition, the sequence value is not a good representation of number
of rows anyway, since you may have deleted rows or non-committed rows
(errors, rollback). If you want number of rows in table, you want
select count(*) from table.
From | Date | Subject | |
---|---|---|---|
Next Message | Ludwig Meyerhoff | 2001-05-05 19:31:52 | Re: Sequences - problem |
Previous Message | Dave Cramer | 2001-05-05 18:52:47 | Re: OODBMS vs. RDBMS |