Rules

Rules

am 15.06.2010 08:09:11 von Ricardo Bayley

--001636c5bf51a697e804890b718d
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

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 =3D 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

--001636c5bf51a697e804890b718d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi Fellows,


I have a table with 55 columns or so, plus o=
ne extra column of datatype geometry, I am using PostGIS.
I inten=
d to split my table into 3 tables. So each may have 25 to 30 columns each.<=
/div>

I've  created a View which relates all 3 table=
s with their pk and fk accordingly. This VIEW has a RULE ..... 
<=
div>
ont class=3D"Apple-style-span" color=3D"#3366FF">ON INSERT TO public.mytabl=
e 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 ins=
ert 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 =3D t=
o the last primary key.


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

Do you kno=
w how should I accomplish this ? Any ideas ?



Thanks in advanced.


Rica=
rdo


--001636c5bf51a697e804890b718d--