Re: Returning oid or primary key

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Ned Wolpert <ned(dot)wolpert(at)knowledgenet(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Returning oid or primary key
Date: 2001-05-03 17:29:55
Message-ID: 200105031729.f43HTtG07022@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

-- Start of PGP signed section.
> (If this is the second time you've seen this message, sorry about that...
> it didn't seem to go through the first time I sent it.)
>
>
> Folks-
>
> I've got an idea on a possible extension to the jdbc driver. I want
> to submit a patch, but only if others think it makes sense. I want to
> add a 'clause' that would slightly change the return value of the
> executeUpdate(String) method in the Statment class. The goal is to
> allow the return of the oid instead of the number of rows affected in
> certain cases. For example:
>
> insert into tablename(name) values('sample') returning oid
>
> as the string would cause the returning value of the executeUpdate()
> method to be the oid of inserted row (if successful) instead of the
> count of updated rows.
>
> I like the idea since I can now use standard pooling managers (like
> PoolMan) and have access to the oid without having access to the
> postgresql Statement class. Of course, the problem is that I'm now
> 'overloading' the returning value of the method, which is ugly. Also,
> 'faking' SQL syntax in the jdbc driver that doesn't exist in the
> postgresql backend may also be problematic. Since callable statement
> doesn't support returned values yet, I figure this would help.

So you really want the OID from the update? We want to add RETURNING to
the standard SQL capabilities of the backend.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Ned Wolpert 2001-05-03 17:40:44 Re: Returning oid or primary key
Previous Message Ned Wolpert 2001-05-03 15:48:38 Returning oid or primary key