Sequences - problem

From: Ludwig Meyerhoff <ludwig(at)antar(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Sequences - problem
Date: 2001-05-05 16:27:30
Message-ID: Pine.LNX.4.21.0105051817560.18284-100000@ludwig
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hallo!

I created several tables using a id-sequence for each:
create sequence portid;
create table ports(id integer primary key default nextval('portid'), name
varchar);

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

What does the problem consist in, and how can I solve it?

In my opinion it is better to read out the counter instead of querying all
elements in a table, so to get the number of elements ...
Pg::doQuery("select * from ports;", \(at)ports);
Where the number I am looking for is $#ports then ...

I think this method will take a lot of time and is not very effective, as
I do not think I wil ever access one of the entrys read (at least not
while putting some information) ...

Saluti!

Ludwig

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joel Burton 2001-05-05 16:29:18 Re: Re: a primer on trigger?
Previous Message Joel Burton 2001-05-05 16:16:54 Re: Postgresql table reloading