RETURNING clause: how to specifiy column indexes?

From: Ken Johanson <pg-user(at)kensystem(dot)com>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: RETURNING clause: how to specifiy column indexes?
Date: 2007-12-12 05:53:42
Message-ID: 475F7766.2040005@kensystem.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

I am attempting to implement (in a driver)(PG JDBC) support for
specifying which column indexes (that generated keys) to return, so I'm
searching for a way to get the server to return the values of the
columns by their index, not name. By name, it is simply to append the
RETURNING clause and column names to the query:

INSERT... RETURNING foo,bar

Does anyone know how (if) this is possible by index? A standard or
server-specific syntax is fine since this is being implemented in a
server-driver.

Something like?:

INSERT... RETURNING [1],[2] (obviously this will not work)

Would I otherwise need to?:

INSERT... RETURNING *

then extract the user-requested columns? This seems inefficient as it
returns all columns / non-key ones (blobs etc).

While the values of an API that specifies the table's columns by
ordinaility may seem dubious, it is an API that I think should be
implemented anyway.

Thanks,
Ken

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-12-12 05:56:50 Re: Terminology definitions/meaning
Previous Message pilzner 2007-12-12 05:42:55 Better alternative for Primary Key then serial??

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tom Lane 2007-12-12 06:07:24 Re: RETURNING clause: how to specifiy column indexes?
Previous Message Matt Magoffin 2007-12-12 04:42:03 how to set a PreparedStatement column of XML type in 8.3?