Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem With PostgreSQL Sequences

796254Jun 18 2006 — edited Jun 19 2006
I know this is a Java forum, but I'm hoping that one of those smart Hibernate folks will be able to help me.

I've created a simple table in PostgreSQL 8.1 called PERSON:
REATE TABLE "PERSON"
(
  "PERSON_ID" int4 NOT NULL DEFAULT nextval('"PERSON_PERSON_ID_seq"'::regclass),
  "FIRST_NAME" varchar,
  "LAST_NAME" varchar NOT NULL,
  CONSTRAINT "PK_PERSON" PRIMARY KEY ("PERSON_ID")
) 
WITHOUT OIDS;
ALTER TABLE "PERSON" OWNER TO pgsuper;
The PERSON_ID column is type serial - like an Oracle sequence. PostgreSQL automatically created a sequence named PERSON_PERSON_ID_seq for me.

I'm having problems getting the next ID out of that sequence.

If I go into the PostgreSQL admin console and do some INSERTs, all is well. But when I try to execute this SELECT in JDBC I have problems. I'm using the query that the PostgreSQL documentation says is correct:
SELECT nextval("PERSON_PERSON_ID_seq")
I get back a SQL state 42703 and the following exception:
org.postgresql.util.PSQLException: ERROR: column "PERSON_PERSON_ID_seq" does not exist
Does anyone have any advice as to how I should proceed? Thanks - %
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 17 2006
Added on Jun 18 2006
9 comments
942 views