| From: | "Guy Rouillier" <guyr(at)masergy(dot)com> | 
|---|---|
| To: | <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Re: basic trigger using OLD not working? | 
| Date: | 2005-02-24 23:49:47 | 
| Message-ID: | CC1CF380F4D70844B01D45982E671B2348E641@mtxexch01.add0.masergy.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
The RAISE statement requires a % marker for each variable you want to
include in the output text.
--
Guy Rouillier
	-----Original Message-----
	From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Rick Casey
	Sent: Thursday, February 24, 2005 5:51 PM
	To: pgsql-general(at)postgresql(dot)org
	Subject: Re: [GENERAL] basic trigger using OLD not working?
	
	
	Thanks much! That met with  partial success; but getting closer.
	
	The error message about OLD went away (thankfully!), but there
is still no data from the OLD variable. Here is the code again:
	
	create trigger PEDIGREES_hist_del_trig
	AFTER DELETE
	on PEDIGREES
	FOR EACH ROW
	EXECUTE PROCEDURE logPedigreesDel();
	
	
	CREATE OR REPLACE FUNCTION logPedigreesDel() RETURNS TRIGGER AS
'
	begin
	    RAISE EXCEPTION ''OLD.famindid = '', OLD.famindid;
	    return OLD;
	end;
	' LANGUAGE plpgsql;
	
	Which when it fires results in:
	cgb_lab_data=# \i testphdtrig.sql
	psql:testphdtrig.sql:1: ERROR:  OLD.famindid =
	
	Regards,
	rick
	
	
	
	Tom Lane wrote: 
		Rick Casey <rick(dot)casey(at)colorado(dot)edu>
<mailto:rick(dot)casey(at)colorado(dot)edu>  writes:
		  
			Here is the code that creates the delete
trigger:
			create trigger PEDIGREES_hist_del_trig
			AFTER DELETE
			on PEDIGREES
			EXECUTE PROCEDURE logPedigreesDel();
			    
		
		I think you forgot FOR EACH ROW.  By default, the above
creates a
		STATEMENT trigger, in which you don't have access to
individual rows.
		
					regards, tom lane
		  
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruce Momjian | 2005-02-24 23:50:20 | Re: Porting Postgres on VXworks+SH4 | 
| Previous Message | Postgres Coder | 2005-02-24 23:46:28 | Which query is less expensive / faster? |