From: | Mario Olimpio de Menezes <mario(at)curiango(dot)ipen(dot)br> |
---|---|
To: | pgsql-sql(at)postgreSQL(dot)org |
Subject: | please help me on pl/pgsql triggers (fwd) |
Date: | 1999-11-18 09:49:33 |
Message-ID: | Pine.LNX.3.96.991118074659.8801A-100000@curiango.ipen.br |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 purpose that 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(dot)Rao(at)toa(dot)toasia(dot)co(dot)jp>
To: mario(at)curiango(dot)ipen(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | secret | 1999-11-18 16:08:59 | Can't create an index on NUMERIC(x,y) |
Previous Message | Gerhard Dieringer | 1999-11-18 08:01:11 | Antw: [SQL] Building "ON DELETE" rules to keep the referential integrity of a database |