Inserting Data - Mailing list pgsql-general

From Bob Pawley
Subject Inserting Data
Date
Msg-id 011301c6c2e3$3aaed960$8e904618@owner
Whole thread Raw
Responses Re: Inserting Data
Re: Inserting Data
List pgsql-general
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

pgsql-general by date:

Previous
From: Michael Meskes
Date:
Subject: Re: Connection string
Next
From: "Merlin Moncure"
Date:
Subject: Re: Migrating PostgreSQL database to MySQL/MS Access