""Marcin Stêpnicki"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] ... > > I think that you either misunderstood this statement or try to break your > application in a nasty way ;). Please tell us more about your problem > and/or what do you want to achive, because sequences behave this way for a > reason (concurrency issues). Perhaps there is another solution.
I have a table with a serial primary key aoto generated by a sequence. I add/remove records. At a moment I'd like to know what is the current value of the sequence. I don't wish to know this in the same session where I add/remove records. My Postgresql version is "PostgreSQL 8.2.3 on i686-pc-mingw32, compiled by GCC gcc.exe (GCC) 3.4.2 (mingw-special)", on Windows XP OS, and I use pgAdmin to open sessions on my database. With this environment, try the following scenario: Make a demo table: CREATE TABLE "tbFoo" ( "ID" integer NOT NULL DEFAULT nextval('"tbFoo_ID_seq"'::regclass) ) At the beginning, no record are inserted in the table. I call: SELECT currval( pg_get_serial_sequence('"tbFoo"','ID') ); This rise the following error: ERROR: currval of sequence "tbFoo_ID_seq" is not yet defined in this session SQL state: 55000 Then I add a record there: INSERT INTO "tbFoo" DEFAULT VALUES; I call SELECT currval( pg_get_serial_sequence('"tbFoo"','ID') ), and I get 1. That's ok because I just use indirectly a nextval to that sequence in the insert process, on this session. I close the session, and I open another one. I call SELECT currval( pg_get_serial_sequence('"tbFoo"','ID') ), and I get the error again: ERROR: currval of sequence "tbFoo_ID_seq" is not yet defined in this session SQL state: 55000 Sabin ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq