X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BACC6474E44 for ; Thu, 6 Feb 2003 08:44:49 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id F1063474E42 for ; Thu, 6 Feb 2003 08:44:47 -0500 (EST) Received: from klaster.net (pa176.krakow.cvx.ppp.tpnet.pl [213.76.36.176]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id E467C2B884; Thu, 6 Feb 2003 14:37:48 +0100 (CET) Message-ID: <3E4267F4.6020302@klaster.net> Date: Thu, 06 Feb 2003 14:49:40 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; PL; rv:1.1) Gecko/20020826 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: =?ISO-8859-1?Q?Maur=EDcio_Sessue_Otta?= Cc: LISTA POSTGRES Subject: Re: Trigger para fazer log References: <002301c2cdd8$30b82640$830101c0@mauricio1> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/117 X-Sequence-Number: 11515 Maur=EDcio Sessue Otta wrote: > Oi lista, >=20=20 > tenho um trigger que deve validar alguns campos para entrada/saida de=20 > funcionarios e que deve fazer um "log" > do que vai acontecendo. >=20=20 > Por exemplo: > quando =E9 o in=EDcio do expediente, o trigger dever=E1 guardar algo assi= m no=20 > "log": > Cadastro da Entrada-1: Data 2003-02-06 Hor=E1rio: 09:51:00 >=20=20 > Se o funcionario tentar burlar o esquema e tentar inserir/atualizar o=20 > registro, o trigger deve guardar na tabela log que > foi feita essa tentativa e retornar um erro para o meu script PHP. >=20=20 > Meu problema: > no fim do trigger tenho o seguinte: > IF length(m_erro) =3D 0 THEN > ELSE > RAISE EXCEPTION ''%'', m_erro; > END IF; > RETURN null; > Quando est=E1 "EXCEPTION", o que deveria ser guardado no "log" tamb=E9m = =E9=20 > desfeito. Quando coloco "NOTICE", a > informa=E7=E3o vai para o LOG. >=20=20 > Como fazer para o trigger gerar uma "EXCEPTION" e mesmo assim gravar em= =20 > outra tabela?!?! >=20=20 >=20=20 > []'s Mauricio I can't understand your language ;-) but I suppose, that after "RAISE EXCEP= TION" you can't find any information in a log table? RAISE EXCEPTION always aborts transaction and you can't put any log informa= tion into tables when doing this. Regards, Tomasz Myrta