Rules

From: Ricardo Bayley <ricardo(dot)bayley(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Rules
Date: 2010-06-15 06:09:11
Message-ID: AANLkTikrQQJZwzr7TuQIwgtB8iWIjQauaFZJmGaPqd8b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi Fellows,

I have a table with 55 columns or so, plus one extra column of datatype
geometry, I am using PostGIS.
I intend to split my table into 3 tables. So each may have 25 to 30 columns
each.

I've created a View which relates all 3 tables with their pk and fk
accordingly. This VIEW has a RULE .....

*ON INSERT TO public.mytable DO INSTEAD*
I listed 3 ACTIONS in order to insert data into all 3 different tables.

I am having trouble getting the main table´s primary key value. I use the
currval('mytable_sequence_id')
It works fine only if I do not insert multiple records at once. If I do
insert multiple records, the currval gets the last value and not each
inserted value. Hence, all my records in my 2 related tables have foreign
key = to the last primary key.

I guess I am doing something wrong, either I am missing something or my
approach is incorrect.

Do you know how should I accomplish this ? Any ideas ?

Thanks in advanced.

Ricardo

Browse pgsql-admin by date

  From Date Subject
Next Message Gnanakumar 2010-06-15 06:37:26 Re: Fatal Error during PITR Recovery
Previous Message Tom Lane 2010-06-14 17:36:27 Re: Server crash when using dblink_build_sql_* after alter table