Re: history tables with only one function?

From: Raphael Bauduin <raphael(dot)bauduin(at)be(dot)easynet(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andreas Haumer <andreas(at)xss(dot)co(dot)at>, pgsql-general(at)postgresql(dot)org
Subject: Re: history tables with only one function?
Date: 2004-08-12 15:18:54
Message-ID: 411B8A5E.1040207@be.easynet.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> Raphael Bauduin <raphael(dot)bauduin(at)be(dot)easynet(dot)net> writes:
>
>>>Could you please confirm that your function works as you described?
>
>
>>It works as expected:
>
>
>>log=# DROP TRIGGER "customers_update_log_t" on "customers";
>>DROP TRIGGER
>>log=# DROP FUNCTION "update_log"();
>>ERROR: function update_log() does not exist
>>log=# CREATE FUNCTION "update_log"(text) RETURNS trigger AS '
>>log'# BEGIN
>>log'# insert into $1_log select new.*,''UPDATE'';
>>log'# return new;
>>log'# END;
>>log'# ' LANGUAGE 'plpgsql';
>>CREATE FUNCTION
>>log=#
>>log=# CREATE TRIGGER "customers_update_log_t" after UPDATE on "customers" for each row execute procedure "customers_update_log"('customers');
>>CREATE TRIGGER
>
>
> That trigger is not executing that function, and would not be executing
> it even if you had used the same function name. Trigger functions are
> always parameterless.

I tested it again and it worked, but the fact you were as categoric made me start from scratch, and you are absolutely right.
As you can even see in the code above, the trigger uses "customers_update_log"('customers') but I define the function "update_log"().....
There was a parameterless function customers_update_log I had defined in previous tests which hadn't been dropped.... And that
was the function used by the trigger, even if I passed a parameter. The fact that it worked made me think it used the parameter.

Thanks for the clarification!

Raph

>
> regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message max jacob 2004-08-12 15:25:26 Re: table functions as fields in a select
Previous Message Paramveer.Singh 2004-08-12 15:08:32 Re: pl pgsql grammer file contains error