please help me on pl/pgsql triggers (fwd) - Mailing list pgsql-sql

From Mario Olimpio de Menezes
Subject please help me on pl/pgsql triggers (fwd)
Date
Msg-id Pine.LNX.3.96.991118074659.8801A-100000@curiango.ipen.br
Whole thread Raw
List pgsql-sql
Hi,
I received this message, but I think it should go here.Please, reply directly to the original sender.Thanks,

[]s,
Mario O.de Menezes            "Many are the plans in a man's heart, but   IPEN-CNEN/SP                 is the Lord's
purposethat prevails"
 
http://curiango.ipen.br/~mario                 Prov. 19.21                  http://www.revistalinux.com.br

---------- Forwarded message ----------
Date: Thu, 18 Nov 1999 18:41:07 +0900
From: Shanthala Rao <S.Rao@toa.toasia.co.jp>
To: mario@curiango.ipen.br
Subject: please help me on pl/pgsql triggers

My problem goes like this..........

Suppose there are 3 tables say a1,a2,a3.
I want to delete a row from a2 & a3 before
deleting the same row from a1.
I wrote a trigger for this.
The problem is the row in table a2 & a3 are
getting deleted. But the same row in a1 is not
getting deleted.
code is as follows.
create function p_delete() returns opaque as'begin
delete from a2 where a2.id = a1.id;
delete from a3 where a3.id = a1.id;
return old;
end;
'language 'plpgsql';


create trigger t1 before delete on a1
for each row execute procedure p_delete();


Here is the function which first executes the statement
delete from a1 written in JDBC

private void a1_delete()  {  try  {     long id = in.readLong();          PreparedStatement prep =
connection.prepareStatement(      "DELETE FROM a1 WHERE Id=?");     prep.setDouble(1,taskid);     if
(prep.executeUpdate() < 0) {       throw new Exception("Error in  a1 delete");     }  }   catch (Exception e)  {
setError(e);  } }
 

 hope to receive an early reply from u. thanks, Shanthala




pgsql-sql by date:

Previous
From: "Gerhard Dieringer"
Date:
Subject: Antw: [SQL] Building "ON DELETE" rules to keep the referential integrity of a database
Next
From: secret
Date:
Subject: Can't create an index on NUMERIC(x,y)