Re: JDBC problem

From: John McKown <jmckown(at)prodigy(dot)net>
To: BogdanKRomski <b(dot)kromski(at)gaschka(dot)pl>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: JDBC problem
Date: 2000-08-24 23:15:00
Message-ID: Pine.LNX.4.21.0008241808520.2783-100000@linux2.johnmckown.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

The syntax that I've seen is:

insert into KEY_ITEM (key_item_id,keyname) values
(select max(key_item_id)+1,'?' FROM KEY_ITEM);

Just out of curiousity, why not make key_item_id a SERIAL field? That way,
if you don't specify a value, it gets the next value from the associated
sequence.

On Tue, 22 Aug 2000, BogdanKRomski wrote:

> Hello
>
> I'm using the Postgresql 6.5 and i try to perform statement
>
> INSERT into KEY_ITEM (key_item_id,keyName) values(((SELECT
> MAX(key_item_id) FROM KEY_ITEM)+1),?)
>
> and I get the message :
>
> Error: ERROR: parser: parse error at or near "select"
>
> I'm not sure but part "(SELECT MAX(key_item_id) FROM KEY_ITEM)+1)" of
> statement does't work
>
> thanks for all informations
>
> Bogdan Kromski
>
> ps. on Oracle and Sybase it is working correct
>

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message amish seth 2000-08-25 01:13:34 iODBC Driver,psqlODBC at PostgreSQl DB in Solaris
Previous Message Christopher Cain 2000-08-24 19:30:14 JDBC Patch