pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ken Johanson <pg-user@kensystem.com>
Cc: pgsql-general@postgresql.org
Subject: RETURNING clause: how to specifiy column indexes?
Date: Tue, 11 Dec 2007 22:53:42 -0700
Message-ID: <475F7766.2040005@kensystem.com> (raw)
In-Reply-To: <47579FBE.1070503@kensystem.com>
References: <22a9f7570703301215y44a937d0r5faa706bad7948c@mail.gmail.com>
	<4610AA0C.30608@ejurka.com>
	<47579D44.6060005@kensystem.com>
	<47579FBE.1070503@kensystem.com>

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





view thread (11+ messages)  latest in thread

Message-ID: <475F7766.2040005@kensystem.com>
Permalink:  ../475F7766.2040005@kensystem.com/
Also on:    postgresql.org/message-id/475F7766.2040005@kensystem.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: pg-user@kensystem.com, pgsql-general@postgresql.org
  Subject: Re: RETURNING clause: how to specifiy column indexes?
  In-Reply-To: <475F7766.2040005@kensystem.com>
  References: <22a9f7570703301215y44a937d0r5faa706bad7948c@mail.gmail.com> <4610AA0C.30608@ejurka.com> <47579D44.6060005@kensystem.com> <47579FBE.1070503@kensystem.com> <475F7766.2040005@kensystem.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox