Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id D2BFE1337B54 for ; Sun, 20 Feb 2011 10:44:26 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 06662-04 for ; Sun, 20 Feb 2011 14:44:20 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mailserver.gammadue.com (host138-98-static.33-85-b.business.telecomitalia.it [85.33.98.138]) by mail.postgresql.org (Postfix) with ESMTP id 6E71D1337B49 for ; Sun, 20 Feb 2011 10:44:19 -0400 (AST) Received: from localhost (unknown [127.0.0.1]) by mailserver.gammadue.com (Postfix) with ESMTP id AC9F3255AA for ; Sun, 20 Feb 2011 14:43:59 +0000 (UTC) Received: from mailserver.gammadue.com ([127.0.0.1]) by localhost (mailserver.gammadue.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12364-10 for ; Sun, 20 Feb 2011 15:43:59 +0100 (CET) Received: from fluca-laptop.localnet (adsl-ull-249-21.51-151.net24.it [151.51.21.249]) by mailserver.gammadue.com (Postfix) with ESMTP id 9B669240B2 for ; Sun, 20 Feb 2011 15:43:58 +0100 (CET) From: fluca1978@infinito.it To: pgsql-it-generale@postgresql.org Subject: Re: trigger on delete cascade Date: Sun, 20 Feb 2011 15:42:01 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.35-25-generic; KDE/4.6.0; x86_64; ; ) References: <447805.9668.qm@web25602.mail.ukl.yahoo.com> In-Reply-To: <447805.9668.qm@web25602.mail.ukl.yahoo.com> MIME-Version: 1.0 Message-Id: <201102201542.02101.fluca1978@infinito.it> Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: amavisd-new at gammadue.com X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.364 tagged_above=-10 required=5 tests=BAYES_50=0.8, FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: ** X-Archive-Number: 201102/2 X-Sequence-Number: 213 MI viene da dire che quello che potrebbe fare al caso tuo sia una regola su= =20 Documento che scatti al DELETE e che esegua INSTEAD la delete cascade e una= =20 stored procedure (la stessa che avresti usato per il trigger). Luca On Wednesday, February 09, 2011 02:31:29 AM Ludovico Bonifacio's cat walkin= g=20 on the keyboard wrote: > Ciao a tutti! > Esiste un modo per attivare un trigger(il cui scopo =E8 di salvare ci=F2= che > si elimina) > non su un evento sulla tabella per cui =E8 stato creato ma per effetto di > una cancellazione di un valore riferito in un altra tabella?? > Ad esempio ho: > il trigger che si attiva > AFTER DELETE ON Documento >=20 > e in Utente ho > id_utente ON DELETE CASCADE >=20 > quindi appena cancello un utente da Utente, giustamente il trigger non > riconosce la DELETE perch=E8 la rileva su Documento. > Esiste un modo per fargli rilevare al Trigger di attivarsi anche nel caso= =20 > di eliminazioni on cascade da altre tabelle(in modo da salvare nella > tabella archivio ci=F2 che viene eliminato da Documento)? > Se si quale? > Se no, come potrei fare? >=20 > Nello specifico le tabelle sono cos=EC: > CREATE TABLE Documento > ( > id_documento INTEGER PRIMARY KEY, > id_utente INTEGER REFERENCES Utente(id_utente) > ON UPDATE CASCADE > ON DELETE CASCADE); >=20 > CREATE TABLEUtente > ( > id_utente INTEGER PRIMARY KEY; > ); >=20 > Grazie in anticipo a tutti