From mauricio@cristorei.com.br Thu Feb 6 12:06:10 2003 X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1BA3C4758DC for ; Thu, 6 Feb 2003 07:06:10 -0500 (EST) Received: from cr1.cristorei.net.br (unknown [200.162.160.50]) by postgresql.org (Postfix) with ESMTP id C8B09475458 for ; Thu, 6 Feb 2003 07:06:08 -0500 (EST) Received: from mauricio1 ([200.162.160.203] unverified) by cr1.cristorei.net.br with Microsoft SMTPSVC(5.0.2195.4905); Thu, 6 Feb 2003 10:06:00 -0200 Message-ID: <002301c2cdd8$30b82640$830101c0@mauricio1> From: =?iso-8859-1?Q?Maur=EDcio_Sessue_Otta?= To: "LISTA POSTGRES" Subject: Trigger para fazer log Date: Thu, 6 Feb 2003 10:06:32 -0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0020_01C2CDC7.6CCD8730" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-OriginalArrivalTime: 06 Feb 2003 12:06:00.0585 (UTC) FILETIME=[1D2C0790:01C2CDD8] X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/113 X-Sequence-Number: 11511 This is a multi-part message in MIME format. ------=_NextPart_000_0020_01C2CDC7.6CCD8730 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Oi lista, tenho um trigger que deve validar alguns campos para entrada/saida de funci= onarios e que deve fazer um "log" do que vai acontecendo. Por exemplo: quando =E9 o in=EDcio do expediente, o trigger dever=E1 guardar algo assim = no "log": Cadastro da Entrada-1: Data 2003-02-06 Hor=E1rio: 09:51:00 Se o funcionario tentar burlar o esquema e tentar inserir/atualizar o regis= tro, o trigger deve guardar na tabela log que=20 foi feita essa tentativa e retornar um erro para o meu script PHP. 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= desfeito. Quando coloco "NOTICE", a informa=E7=E3o vai para o LOG. Como fazer para o trigger gerar uma "EXCEPTION" e mesmo assim gravar em out= ra tabela?!?! []'s Mauricio ------=_NextPart_000_0020_01C2CDC7.6CCD8730 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Oi lista,
 
tenho um trigger que deve validar alguns c= ampos=20 para entrada/saida de funcionarios e que deve fazer um "log"
do que vai acontecendo.
 
Por exemplo:
quando =E9 o in=EDcio do expediente, o tri= gger dever=E1=20 guardar algo assim no "log":
Cadastro da Entrada-1: Data 2003-02-06&nbs= p;=20 Hor=E1rio: 09:51:00
 
Se o funcionario tentar burlar o esquema e= tentar=20 inserir/atualizar o registro, o trigger deve guardar na tabela log que=20
foi feita essa tentativa e retornar um err= o para o=20 meu script PHP.
 
Meu problema:
no fim do trigger tenho o seguinte:=
 IF length(m_erro) =3D 0=20 THEN
 ELSE
  RAISE EXCEPTION ''%'', m_erro;
 E= ND=20 IF;
 RETURN null;
Quando est=E1 "EXCEPTION", o que deveria s= er guardado=20 no "log" tamb=E9m =E9 desfeito. Quando coloco "NOTICE", a
informa=E7=E3o vai para o LOG.
 
Como fazer para o trigger gerar uma "EXCEP= TION" e=20 mesmo assim gravar em outra tabela?!?!
 
 
[]'s Mauricio
 
 
------=_NextPart_000_0020_01C2CDC7.6CCD8730-- From jasiek@klaster.net Thu Feb 6 13:44:49 2003 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 From rmello@cc.usu.edu Thu Feb 6 15:51:14 2003 X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6026F47592C for ; Thu, 6 Feb 2003 10:51:14 -0500 (EST) Received: from brasileiro.net (slxwy.dorms.usu.edu [129.123.227.56]) by postgresql.org (Postfix) with ESMTP id E505F47590C for ; Thu, 6 Feb 2003 10:51:13 -0500 (EST) Received: from roberto by brasileiro.net with local (Exim 3.35 #1 (Debian)) id 18goPh-0007CS-00; Thu, 06 Feb 2003 08:58:09 -0700 Date: Thu, 6 Feb 2003 08:58:09 -0700 From: Roberto Mello To: =?iso-8859-1?Q?Maur=EDcio?= Sessue Otta Cc: LISTA POSTGRES Subject: Re: Trigger para fazer log Message-ID: <20030206155809.GF27389@cc.usu.edu> References: <002301c2cdd8$30b82640$830101c0@mauricio1> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <002301c2cdd8$30b82640$830101c0@mauricio1> User-Agent: Mutt/1.4i X-message-flag: Please consider using an e-mail program other than Outlook. It's insecure. Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/118 X-Sequence-Number: 11516 On Thu, Feb 06, 2003 at 10:06:32AM -0200, Maur=EDcio Sessue Otta wrote: >=20 > Quando est=E1 "EXCEPTION", o que deveria ser guardado no "log" tamb=E9m = =E9 desfeito. Quando coloco "NOTICE", a > informa=E7=E3o vai para o LOG. >=20 > Como fazer para o trigger gerar uma "EXCEPTION" e mesmo assim gravar em o= utra tabela?!?! N=E3o d=E1. Quando voc=EA levanta uma exce=E7=E3o (exception) o controle vo= lta para quem chamou o gatilho. N=E3o h=E1 como contornar, que eu saiba. Voc=EA tem que fazer a inser=E7=E3o na rela=E7=E3o desejada antes de levant= ar a exce=E7=E3o (talvez chamando outra fun=E7=E3o que o fa=E7a). -Roberto P.S.: Tomaz, you understood his question correctly :-) --=20 +----| Roberto Mello - http://www.brasileiro.net/ |------+ + Computer Science Graduate Student, Utah State University + + USU Free Software & GNU/Linux Club - http://fslc.usu.edu/ + I'm not super man. But I am very dense.