Insert

From: Bob Pawley <rjpawley(at)shaw(dot)ca>
To: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Insert
Date: 2008-03-23 20:48:28
Message-ID: 036b01c88d27$3f83c3a0$6401a8c0@owner
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have two tables - p_id.association and p_id.devices

If a new row in p_id.association has a value - say 2 in column mon_function
and a value 5 in column monitoring_fluid I want the new value for
mon_function inserted into table p_id.devices ONLY when 2 AND 5 do not
appear in the same row in p_id.devices.

The following gives me a return of "more than one row" and I can't figure
out what's wrong.

Any thoughts would be appreciated.

Bob

Declare
xmon_function varchar;

Begin
Select mon_function into xmon_function
From p_id.association
Where mon_function = new.mon_function;

If xmon_function = p_id.devices.device_number
From p_id.association, p_id.devices
Where p_id.association.monitoring_fluid = p_id.devices.fluid_id
or p_id.association.monitoring_fluid = p_id.devices.pipe_id
Then

Return Null;

Elseif xmon_function = p_id.devices.device_number
or xmon_function != p_id.devices.device_number
From p_id.association, p_id.devices
Where p_id.association.monitoring_fluid != p_id.devices.fluid_id
or p_id.association.monitoring_fluid != p_id.devices.pipe_id

Then
Insert into p_id.devices (device_number) Values (New.mon_function) ;

Return Null;
END if;
End;

Responses

  • Re: Insert at 2008-03-23 21:24:36 from Adrian Klaver

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2008-03-23 21:24:36 Re: Insert
Previous Message Steve Clark 2008-03-23 17:29:44 Re: --enable-thread-safety bug