Search Postgresql Archives

Inserting Data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All
 
I have a basic problem that I hope can be addressed.
 
I need to insert data from one table into three other tables.
 
I attempted the following format.
 

 CREATE OR REPLACE FUNCTION p_id_monitor()
 RETURNS "trigger" AS
 $$
 Begin
 insert into p_id.loops (monitor)
 Select p_id.devices.devices_id
 Where p_id.devices.device_number = library.devices.device_number
 and library.devices.type_ = 'mon' ;
 
 insert into p_id.settings (monitor)
 Select p_id.devices.devices_id
 Where p_id.devices.device_number = library.devices.device_number
 and library.devices.type_ = 'mon' ;
 
 insert into p_id.alarms (monitor)
 Select p_id.devices.devices_id
 Where p_id.devices.device_number = library.devices.device_number
 and library.devices.type_ = 'mon' ;
 
 Return Null ;
 End;
 $$
 LANGUAGE 'plpgsql' ;
 create trigger mon after insert on p_id.devices
 for each row execute procedure p_id_monitor() ;
 
Unfortunately this gave multiple results on the target tables.
 
Is there a format that will give me a single insert for each original field without the need of creating three triggers???
 
Bob

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux