pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: mohansammeta@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #8027: Get generated key value while inserting in partitioned table
Date: Tue, 02 Apr 2013 07:11:27 +0000
Message-ID: <E1UMvNP-0002z1-Fr@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      8027
Logged by:          mohan sammeta
Email address:      mohansammeta@gmail.com
PostgreSQL version: 8.4.0
Operating system:   ubuntu
Description:        



Hi I have a table in Postgres, say email_messages. It is partitioned so
whatever the inserts i do it using my java application will not effect the
master table, as the data is actually getting inserted in the child tables.
Here is the problem, I want to get an auto generated column value (say
email_message_id which is of big serial type). Postgres is returning it as
null since there is no insert being done on master table. For oracle I used
GeneratedKeyHolder to get that value. But I'm unable to do the same for
partitioned table in postgres. Please help me out.

Here is the code snippet we used for oracle

public void createAndFetchPKImpl(final Entity pEntity, final String
pStatementId, final String pPKColumnName) {

final SqlParameterSource parameterSource =
  new BeanPropertySqlParameterSource(pEntity);

  final String[] columnNames = new String[]{"email_message_id"};
  final KeyHolder keyHolder = new GeneratedKeyHolder();
  final int numberOfRowsEffected = mNamedParameterJdbcTemplate.update(
      getStatement(pStatementId), parameterSource, keyHolder, columnNames);
  pEntity.setId(ConversionUtil.getLongValue(keyHolder.getKey()));

}
We are using spring 3.1.1.
I am getting numberOfRowsEffected as zero and keyHolder.getKey() as null
even though the insert is happening in the table.





-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)  latest in thread

Message-ID: <E1UMvNP-0002z1-Fr@wrigleys.postgresql.org>
Permalink:  ../E1UMvNP-0002z1-Fr@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/E1UMvNP-0002z1-Fr@wrigleys.postgresql.org

 · 

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-bugs@postgresql.org
  Cc: mohansammeta@gmail.com
  Subject: Re: BUG #8027: Get generated key value while inserting in partitioned table
  In-Reply-To: <E1UMvNP-0002z1-Fr@wrigleys.postgresql.org>
  References: <E1UMvNP-0002z1-Fr@wrigleys.postgresql.org>

* 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