[partition table] fetchall or fetchone function can not get the returning rows

Started by Xiaoning Xuover 14 years ago3 messagesgeneral
Jump to latest
#1Xiaoning Xu
xixu@bcgsc.ca

Hello,

I have a problem concerning the partition table.
When I store a record into one of the partition and use "RETURNING table_id" or "RETURNING *",
I expect the same result when calling fetchall or fetchone function as not using partition.
However, it simply returns nothing.

Since the serial primary key of my partition table is the FK of some other tables, I need to get the
id after each insertion.
My solution now is to select the max id from the parent table.
I am wondering if there is any other alternatives to solve this problem.

Thank you in advance!
Rachel

#2Xiaoning Xu
xixu@bcgsc.ca
In reply to: Xiaoning Xu (#1)

Hello,

I have a problem concerning the partition table.
When I store a record into one of the partition and use "RETURNING table_id" or "RETURNING *",
I expect the same result when calling fetchall or fetchone function as not using partition.
However, it simply returns nothing.

Since the serial primary key of my partition table is the FK of some other tables, I need to get the
id after each insertion.
My solution now is to select the max id from the parent table.
I am wondering if there is any other alternatives to solve this problem.

Thank you in advance!
Xiaoning

#3John R Pierce
pierce@hogranch.com
In reply to: Xiaoning Xu (#1)
Re: [partition table] fetchall or fetchone function can not get the returning rows

On 12/21/11 10:24 AM, Xiaoning Xu wrote:

Since the serial primary key of my partition table is the FK of some other tables, I need to get the
id after each insertion.
My solution now is to select the max id from the parent table.
I am wondering if there is any other alternatives to solve this problem.

curval('sequencename') after doing the insert will return the correct
value for this transaction, independent of any other concurrent
trnasactions that may be going on. your max() method would fail with
enough concurrency.

--
john r pierce N 37, W 122
santa cruz ca mid-left coast