Hi All,
I am creating the partition table and I want to insert the multiple rows with generate_series function. In my function am inserting 10 rows, in which 5 should go in child1 table and 5 to another child2 table according to the rule set for Partition Table. Please find the example given below as generate series is not allowed as expected.
Creating Partition Tables
postgres=# create table parent(id int);
CREATE TABLE
postgres=# create table child1(check ( id < 6)) inherits (parent);
CREATE TABLE
postgres=# create table child2(check (id >= 6 and id <= 10)) inherits (parent);
CREATE TABLE
Creating Rule for Partition Table
postgres=# create or replace rule insert_child1 as on insert to parent where ( id < 6) do instead insert into child1 values(new.id);
CREATE RULE
postgres=# create or replace rule insert_child2 as on insert to parent where ( id >= 6 and id <= 10) do instead insert into child2 values(new.id);
CREATE RULE
If I insert individually, my partition works
postgres=# insert into parent values (1), (6);
INSERT 0 0
postgres=# \x
Expanded display is on.
postgres=# select * from child1, child2;
-[ RECORD 1 ]
id | 1
id | 6
Here am using generate_series for insertion, this fails
postgres=# insert into parent values(generate_series(1,10));
ERROR: set-valued function called in context that cannot accept a set
Is there any work-around for this…
Thanks in Advance
Regards
Raghavendra