| From: | "Rahul Patil" <rg_patil(at)rediffmail(dot)com> | 
|---|---|
| To: | pgsql-novice(at)postgresql(dot)org | 
| Subject: | can not create trigger with parameter | 
| Date: | 2005-12-15 12:56:30 | 
| Message-ID: | 20051215125630.7907.qmail@webmail28.rediffmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-novice | 
Hi,
I'm having trouble getting a trigger to use a parameter,  as in the
following simplified example:
CREATE FUNCTION fun_version_table(varchar)
RETURNS opaque
AS 'DECLARE
     
        in_table_name ALIAS FOR $1;
        v_counter  integer;
        BEGIN
                SELECT INTO v_counter counter FROM version_table
                WHERE table_name = in_table_name; 	
-- do something in here
                RETURN new;
        END;'
LANGUAGE 'plpgsql';
CREATE TRIGGER trig_deg_master 
AFTER
INSERT OR UPDATE OR DELETE
ON author
FOR EACH ROW
EXECUTE PROCEDURE fun_version_table('degree_master');
Function gets created successfully.But
when I create trigger I get an error:
ERROR:CreateTrigger: function fun_version_table() does not exist
I've created triggers/functions with no parameters and they work fine.
The Postgresql book has some examples of functions with paramters, but
I cannot find anywhere a trigger which calls a function with parameters,
although the users manual indicates that parameters are allowed in the
syntax for CREATE TRIGGER.
  
Regards,
Rahul
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Doug | 2005-12-15 14:09:24 | How populate : variables dynamically? | 
| Previous Message | me | 2005-12-15 12:04:47 | Re: GUID function in pgsql? |