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