From yudha@BonBon.net Fri Jan 17 06:00:27 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 80EB3475BC3 for ; Fri, 17 Jan 2003 01:00:27 -0500 (EST) Received: from babyruth.hotpop.com (babyruth.hotpop.com [204.57.55.14]) by postgresql.org (Postfix) with ESMTP id E747047592C for ; Fri, 17 Jan 2003 01:00:26 -0500 (EST) Received: from bonbon.net (kubrick.hotpop.com [204.57.55.16]) by babyruth.hotpop.com (Postfix) with SMTP id 6C62D210609 for ; Fri, 17 Jan 2003 05:59:31 +0000 (UTC) Received: from yudha (unknown [61.5.113.68]) by smtp-2.hotpop.com (Postfix) with SMTP id 586B61B8636 for ; Wed, 15 Jan 2003 09:05:02 +0000 (UTC) Message-ID: <023f01c2bc75$bdce13b0$ea00a8c0@yudha> From: "Yudha Setiawan" To: Subject: Do Something before Abort on Trigger ??? Date: Wed, 15 Jan 2003 16:08:40 +0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_023A_01C2BCB0.5EBA0330" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-HotPOP: ----------------------------------------------- Sent By HotPOP.com FREE Email Get your FREE POP email at www.HotPOP.com ----------------------------------------------- X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/186 X-Sequence-Number: 7028 This is a multi-part message in MIME format. ------=_NextPart_000_023A_01C2BCB0.5EBA0330 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Somebody gimme your hand plz. Using my previous Database I used to be like that; " ALTER TRIGGER tr_T_DtlPO ON dbo.T_DtlPO FOR UPDATE AS bla..bla..bla... IF @OldQty <> @NewQty BEGIN ROLLBACK INSERT INTO T_My_ListError(fc_code,fv_descript)=20 VALUES('12345','No Authority to Change Qty') END" So I'v already write the error code to table T_My_ListError before aborting= this session ---------------------------------------------------------------------------= -------------- And I Tried on Postgre like that; " create or replace function fn_tr_t_dtlpo returns trigger as' begin bla..bla...; if new.fn_qty !=3D old.fn_qty then=20 raise exception ''Error 12345''; insert into t_my_listerror(fc_code,fv_descript)=20 values(''12345'',''No Authority to Change Qty''); end if; end;' language 'plpgsql'; " But I Couldn't get any records at all on t_my_listerror. Even when put the = insert statement (insert into t_my_listerror...bla..bla) before raise exception. Some advice will be very helpfull to me. Thank's a lot and ... GOD Bless You All. ------=_NextPart_000_023A_01C2BCB0.5EBA0330 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Somebody gimme your hand plz.
 
Using my previous Database I used = to be=20 like that;
" ALTER TRIGGER tr_T_DtlPO&nb= sp;ON=20 dbo.T_DtlPO FOR UPDATE AS
  bla..bla..bla...
  IF @OldQty <> @N= ewQty=20 BEGIN
    =20 ROLLBACK
     INSE= RT=20 INTO T_My_ListError(fc_code,fv_descript)
           =    =20 VALUES('12345','No Authority to Change Qty')
  END"
So I'v already write the error cod= e to=20 table T_My_ListError before aborting this session
------------------------------------------------------------------= -----------------------
And I Tried on Postgre like=20 that;
" create or replace function fn_tr= _t_dtlpo=20 returns trigger as'
  begin
    =20 bla..bla...;
     if new.fn= _qty !=3D=20 old.fn_qty then
     &nbs= p; =20 raise exception ''Error 12345'';
     &nbs= p; =20 insert into t_my_listerror(fc_code,fv_descript)
           =      =20 values(''12345'',''No Authority to Change Qty'');
     end= =20 if;
  end;' language=20 'plpgsql';
"
But I Couldn't get any records at = all on=20 t_my_listerror. Even when put the insert statement
(insert into t_my_listerror...bla.= .bla)=20 before raise exception.
 
Some advice will be very helpfull = to me.=20 Thank's a lot and ...
GOD Bless You All.
 
------=_NextPart_000_023A_01C2BCB0.5EBA0330-- From yudha@BonBon.net Fri Jan 17 01:39:58 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E9F0E475F2F for ; Thu, 16 Jan 2003 20:39:58 -0500 (EST) Received: from rizzo.jerky.net (rizzo.jerky.net [204.57.55.99]) by postgresql.org (Postfix) with ESMTP id 4B2D7475BC3 for ; Thu, 16 Jan 2003 20:39:58 -0500 (EST) Received: from bonbon.net (kubrick.hotpop.com [204.57.55.16]) by rizzo.jerky.net (Postfix) with SMTP id 2A4CD30CED for ; Fri, 17 Jan 2003 01:39:30 +0000 (UTC) Received: from yudha (unknown [61.5.117.26]) by smtp-2.hotpop.com (Postfix) with SMTP id A43D71B8DC4 for ; Fri, 17 Jan 2003 01:36:49 +0000 (UTC) Message-ID: <005c01c2bdc9$77b8c870$ea00a8c0@yudha> From: "Yudha Setiawan" To: Subject: Do Something before Abort on Trigger ??? Date: Fri, 17 Jan 2003 08:23:44 +0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0015_01C2BE01.C02E4DE0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-HotPOP: ----------------------------------------------- Sent By HotPOP.com FREE Email Get your FREE POP email at www.HotPOP.com ----------------------------------------------- X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/185 X-Sequence-Number: 7027 This is a multi-part message in MIME format. ------=_NextPart_000_0015_01C2BE01.C02E4DE0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Somebody Help Me..... Using my previous Database I used to be like that; " ALTER TRIGGER tr_T_DtlPO ON dbo.T_DtlPO FOR UPDATE AS bla..bla..bla... IF @OldQty <> @NewQty BEGIN ROLLBACK INSERT INTO T_My_ListError(fc_code,fv_descript)=20 VALUES('12345','No Authority to Change Qty') END" So I'v already write the error code to table T_My_ListError before aborting= this session ---------------------------------------------------------------------------= -------------- And I Tried on Postgre like that; " create or replace function fn_tr_t_dtlpo returns trigger as' begin bla..bla...; if new.fn_qty !=3D old.fn_qty then=20 raise exception ''Error 12345''; insert into t_my_listerror(fc_code,fv_descript)=20 values(''12345'',''No Authority to Change Qty''); end if; end;' language 'plpgsql'; " But I Couldn't get any records at all on t_my_listerror. Even when put the = insert statement (insert into t_my_listerror...bla..bla) before raise exception. Some advice will be very helpfull to me. Thank's a lot and ... GOD Bless You All. ------=_NextPart_000_0015_01C2BE01.C02E4DE0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Somebody Help Me.....
 
Using my previous Database I used = to be=20 like that;
" ALTER TRIGGER tr_T_DtlPO&nb= sp;ON=20 dbo.T_DtlPO FOR UPDATE AS
  bla..bla..bla...
  IF @OldQty <> @N= ewQty=20 BEGIN
    =20 ROLLBACK
     INSE= RT=20 INTO T_My_ListError(fc_code,fv_descript)
           =    =20 VALUES('12345','No Authority to Change Qty')
  END"
So I'v already write the error cod= e to=20 table T_My_ListError before aborting this session
------------------------------------------------------------------= -----------------------
And I Tried on Postgre like=20 that;
" create or replace function fn_tr= _t_dtlpo=20 returns trigger as'
  begin
    =20 bla..bla...;
     if new.fn= _qty !=3D=20 old.fn_qty then
     &nbs= p; =20 raise exception ''Error 12345'';
     &nbs= p; =20 insert into t_my_listerror(fc_code,fv_descript)
           =      =20 values(''12345'',''No Authority to Change Qty'');
     end= =20 if;
  end;' language=20 'plpgsql';
"
But I Couldn't get any records at = all on=20 t_my_listerror. Even when put the insert statement
(insert into t_my_listerror...bla.= .bla)=20 before raise exception.
 
Some advice will be very helpfull = to me.=20 Thank's a lot and ...
GOD Bless You All.
 
------=_NextPart_000_0015_01C2BE01.C02E4DE0-- From nandrews@investsystems.co.uk Fri Jan 17 08:41:06 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 78F47476865 for ; Fri, 17 Jan 2003 03:41:06 -0500 (EST) Received: from smtp.investsystems.co.uk (unknown [62.49.196.163]) by postgresql.org (Postfix) with SMTP id 0F88A4761A3 for ; Fri, 17 Jan 2003 03:40:55 -0500 (EST) Received: (qmail 14482 invoked from network); 17 Jan 2003 08:40:40 -0000 Received: from ponder.fairway2k.co.uk (nandrews@172.31.1.3) by hex.fairway2k.co.uk with SMTP; 17 Jan 2003 08:40:40 -0000 Date: Fri, 17 Jan 2003 08:40:40 +0000 (GMT) From: "Nigel J. Andrews" X-Sender: nandrews@ponder.fairway2k.co.uk To: Yudha Setiawan Cc: pgsql-admin@postgresql.org Subject: Re: Do Something before Abort on Trigger ??? In-Reply-To: <023f01c2bc75$bdce13b0$ea00a8c0@yudha> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/222 X-Sequence-Number: 7064 On Wed, 15 Jan 2003, Yudha Setiawan wrote: > Somebody gimme your hand plz. > > Using my previous Database I used to be like that; > " ALTER TRIGGER tr_T_DtlPO ON dbo.T_DtlPO FOR UPDATE AS > bla..bla..bla... > IF @OldQty <> @NewQty BEGIN > ROLLBACK > INSERT INTO T_My_ListError(fc_code,fv_descript) > VALUES('12345','No Authority to Change Qty') > END" > So I'v already write the error code to table T_My_ListError before aborting this session > ----------------------------------------------------------------------------------------- > And I Tried on Postgre like that; > " create or replace function fn_tr_t_dtlpo returns trigger as' > begin > bla..bla...; > if new.fn_qty != old.fn_qty then > raise exception ''Error 12345''; > insert into t_my_listerror(fc_code,fv_descript) > values(''12345'',''No Authority to Change Qty''); > end if; > end;' language 'plpgsql'; > " > But I Couldn't get any records at all on t_my_listerror. Even when put the insert statement > (insert into t_my_listerror...bla..bla) before raise exception. Well you're aborting the transaction, your function is part of the transaction, so any changes it makes to t_my_listerror will be aborted (or rolled back). Ah, I see that you're raising the exception before you insert even. Why would you expect control to reach the insert statement? I imagine the only remotely sensible way to achieve what you want is to log to file. That would need a trusted language installed. I can't see using the standard postgresql log output being terrible useful for you, besides, you seem to be using the exception notice to return information somewhere. -- Nigel J. Andrews From nandrews@investsystems.co.uk Fri Jan 17 12:05:31 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 02307476708 for ; Fri, 17 Jan 2003 07:05:31 -0500 (EST) Received: from smtp.investsystems.co.uk (unknown [62.49.196.163]) by postgresql.org (Postfix) with SMTP id 00AB8477226 for ; Fri, 17 Jan 2003 07:04:06 -0500 (EST) Received: (qmail 14770 invoked from network); 17 Jan 2003 12:04:07 -0000 Received: from ponder.fairway2k.co.uk (nandrews@172.31.1.3) by hex.fairway2k.co.uk with SMTP; 17 Jan 2003 12:04:07 -0000 Date: Fri, 17 Jan 2003 12:04:06 +0000 (GMT) From: "Nigel J. Andrews" X-Sender: nandrews@ponder.fairway2k.co.uk To: Yudha Setiawan Cc: pgsql-admin@postgresql.org, pgsql-general@postgresql.org Subject: Re: Do Something before Abort on Trigger ??? In-Reply-To: <00f401c2be13$7a229ce0$ea00a8c0@yudha> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/223 X-Sequence-Number: 7065 I'm going to CC this to the -general list as well, it's possible that -admin isn't the right list for this thread. You can not rollback or commit within a function. That would require nested transactions which aren't implemented yet. Obviously that precludes use of your 'begin work' in your function. All this means that you can not store your history records and have the transaction rollback. However, you are using a before trigger (I presume the created function name is a typo below) so to store a history but not the new data you can return NULL from your function. To proceed with the insert simply return NEW, with whatever modifications of it's data you require. So you have something along the lines of: create function aaa ( ) returns trigger as ' begin insert into log_table values ( new.fn_value ); if fn_value < 10 then insert into log_table values ( new.fn_value * 10 ); return null; endif return new; end ' language 'plpgsql'; Hope this helps you (and that I haven't made any nasty misdirection mistakes). -- Nigel J. Andrews On Fri, 17 Jan 2003, Yudha Setiawan wrote: > > ----- Original Message ----- > From: "Nigel J. Andrews" > To: "Yudha Setiawan" > Cc: > Sent: Friday, January 17, 2003 3:40 PM > Subject: Re: [ADMIN] Do Something before Abort on Trigger ??? > > > > Well you're aborting the transaction, your function is part of the > transaction, > > so any changes it makes to t_my_listerror will be aborted (or rolled > > back). Ah, I see that you're raising the exception before you insert even. > Why > > would you expect control to reach the insert statement? > > > > I imagine the only remotely sensible way to achieve what you want is to > log to > > file. That would need a trusted language installed. I can't see using the > > standard postgresql log output being terrible useful for you, besides, you > seem > > to be using the exception notice to return information somewhere. > > > > > -- > > Nigel J. Andrews > > > What big of thanks of me for you for the Adviced. It's a smart solutions but > One things you should know, we don't wanna take a long time to Porting > the Front-End. We have a lot of Job to be done and the "Time is Getting > Closer". > Our application is used to be taking a record from t_my_listerror for > knowing > the Error and then Showed to the User. We have a table for List Error Named > T_BDE_Error. Before i reads this reply, I've tried this one; > > " > drop function fn_tr_bi_pulse() cascade; > create or replace function fn_tr_bi_yyy() returns trigger as ' > begin > begin work; > insert into d_history.t_history_value (fn_value,fv_descript) > values(new.fn_values,''For History''); > if (new.fn_value * 20) >= 1000 then > insert into d_history.t_history_value (fn_value,fv_descript) > values(new.fn_values,''Invalid Values''); > rollback; > else > commit; > end if; > return new; > end;' language 'plpglsql'; > create trigger tr_bi_pulse before insert on d_transaction.t_pulse for each > row > execute procedure fn_tr_bi_pulse(); > " > There was no Error Show-up when i Compiling, but when i tried to inserting a > record > An Error is Show-Up. Do you have any ideas...??? Gimme your another best > ones; > From reedstrm@rice.edu Fri Jan 17 15:42:27 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 522A7475E91 for ; Fri, 17 Jan 2003 10:42:27 -0500 (EST) Received: from ece.rice.edu (ece.rice.edu [128.42.4.34]) by postgresql.org (Postfix) with ESMTP id CFA88475E1E for ; Fri, 17 Jan 2003 10:42:26 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by ece.rice.edu (Postfix) with SMTP id 6C3AC68AAC; Fri, 17 Jan 2003 09:42:31 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by ece.rice.edu (Postfix) with ESMTP id 1EB5A68A6F; Fri, 17 Jan 2003 09:42:31 -0600 (CST) Received: from wallace.ece.rice.edu (wallace.ece.rice.edu [128.42.12.154]) by ece.rice.edu (Postfix) with ESMTP id 54BEF68A5B; Fri, 17 Jan 2003 09:42:30 -0600 (CST) Received: from reedstrm by wallace.ece.rice.edu with local (Exim 3.36 #1 (Debian)) id 18ZYdZ-0004CJ-00; Fri, 17 Jan 2003 09:42:29 -0600 Date: Fri, 17 Jan 2003 09:42:29 -0600 From: "Ross J. Reedstrom" To: Yudha Setiawan Cc: pgsql-admin@postgresql.org Subject: Re: Do Something before Abort on Trigger ??? Message-ID: <20030117154229.GA15778@wallace.ece.rice.edu> Mail-Followup-To: "Ross J. Reedstrom" , Yudha Setiawan , pgsql-admin@postgresql.org References: <023f01c2bc75$bdce13b0$ea00a8c0@yudha> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <023f01c2bc75$bdce13b0$ea00a8c0@yudha> User-Agent: Mutt/1.4i X-Virus-Scanned: by AMaViS snapshot-20020300 X-DCC--Metrics: ece.rice.edu 1066; Body=1 Fuz1=1 Fuz2=1 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/192 X-Sequence-Number: 7034 On Wed, Jan 15, 2003 at 04:08:40PM +0700, Yudha Setiawan wrote: > Somebody gimme your hand plz. > > Using my previous Database I used to be like that; > " ALTER TRIGGER tr_T_DtlPO ON dbo.T_DtlPO FOR UPDATE AS > bla..bla..bla... > IF @OldQty <> @NewQty BEGIN > ROLLBACK > INSERT INTO T_My_ListError(fc_code,fv_descript) > VALUES('12345','No Authority to Change Qty') > END" > So I'v already write the error code to table T_My_ListError before aborting this session > ----------------------------------------------------------------------------------------- > And I Tried on Postgre like that; > " create or replace function fn_tr_t_dtlpo returns trigger as' > begin > bla..bla...; > if new.fn_qty != old.fn_qty then > raise exception ''Error 12345''; > insert into t_my_listerror(fc_code,fv_descript) > values(''12345'',''No Authority to Change Qty''); > end if; > end;' language 'plpgsql'; > " > But I Couldn't get any records at all on t_my_listerror. Even when put the insert statement > (insert into t_my_listerror...bla..bla) before raise exception. Hmm, I think you may be out of luck, if you really _have_ to abort the transaction, since PostgreSQL has no way to violate the transactional integrity: anything you do inside a function that's in a transaction that fails will rollback. Alternatively, you can supress the UPDATE by setting new.fn_qty = old.fn_qty, INSERTing a line in your errors table, and even firing off a NOTICE so an LISTENing frontend can tell the user about the problem. This will let the rest of the transaction commit, however. Sorry, Ross -- Ross Reedstrom, Ph.D. reedstrm@rice.edu Research Scientist phone: 713-348-6166 The Connexions Project http://cnx./rice.edu fax: 713-348-6182 Rice University MS-39 Houston, TX 77005 From yudha@BonBon.net Mon Jan 20 03:26:33 2003 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8D4EB474E61 for ; Sun, 19 Jan 2003 22:26:33 -0500 (EST) Received: from snickers.hotpop.com (snickers.hotpop.com [204.57.55.49]) by postgresql.org (Postfix) with ESMTP id E258C474E44 for ; Sun, 19 Jan 2003 22:26:32 -0500 (EST) Received: from bonbon.net (kubrick.hotpop.com [204.57.55.16]) by snickers.hotpop.com (Postfix) with SMTP id 0859E74550 for ; Mon, 20 Jan 2003 03:26:16 +0000 (UTC) Received: from yudha (unknown [61.5.117.116]) by smtp-1.hotpop.com (Postfix) with SMTP id A331D2F8111 for ; Mon, 20 Jan 2003 03:25:51 +0000 (UTC) Message-ID: <00a701c2c034$3c7295d0$ea00a8c0@yudha> From: "Yudha Setiawan" To: Subject: Re: Do Something before Abort on Trigger ??? Date: Mon, 20 Jan 2003 10:29:39 +0700 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00A4_01C2C06E.D66A6E30" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-HotPOP: ----------------------------------------------- Sent By HotPOP.com FREE Email Get your FREE POP email at www.HotPOP.com ----------------------------------------------- X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/200 X-Sequence-Number: 7042 This is a multi-part message in MIME format. ------=_NextPart_000_00A4_01C2C06E.D66A6E30 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thank's so much to all of you guys. You have giving me completely explainations about the=20 transactional on Postgre-SQL especially to Nigel J. Andrews and Ross J. Reedstrom . GOD Bless U All. Yudha Setiawan. VoIP; No. : 01119311223344 Gatekeeper : 202.43.162.189 ------=_NextPart_000_00A4_01C2C06E.D66A6E30 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Thank's so much to all of you guys= . You=20 have
giving me completely explaina= tions=20 about the
transactional on Postgre-SQL espec= ially=20 to
Nigel J. Andrews <nandrews@investsystems.co.uk>=20 and
Ross J. Reedstrom <reedstrm@rice.edu>.
 
GOD Bless U All.
 
Yudha=20 Setiawan.
VoIP;
   =20 No.        :=20 01119311223344
    Gatekeeper :=20 202.43.162.189
------=_NextPart_000_00A4_01C2C06E.D66A6E30--