pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #8027: Get generated key value while inserting in partitioned table
2+ messages / 2 participants
[nested] [flat]
* BUG #8027: Get generated key value while inserting in partitioned table
@ 2013-04-02 07:11 mohansammeta@gmail.com
0 siblings, 1 reply; 2+ messages in thread
From: mohansammeta@gmail.com @ 2013-04-02 07:11 UTC (permalink / raw)
To: pgsql-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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #8027: Get generated key value while inserting in partitioned table
@ 2013-04-02 14:39 bricklen <bricklen@gmail.com>
parent: mohansammeta@gmail.com
0 siblings, 0 replies; 2+ messages in thread
From: bricklen @ 2013-04-02 14:39 UTC (permalink / raw)
To: mohansammeta@gmail.com; +Cc: pgsql-bugs
This is not a bug, so should not be in the bugs list. Try posting in the
pgsql-general list if the point below does not help.
Are your insert statements into the child tables including "RETURNING
email_message_id" ?
On Tue, Apr 2, 2013 at 12:11 AM, <mohansammeta@gmail.com> wrote:
> 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
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2013-04-02 14:39 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-04-02 07:11 BUG #8027: Get generated key value while inserting in partitioned table mohansammeta@gmail.com
2013-04-02 14:39 ` bricklen <bricklen@gmail.com>
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