Re: UDF to access OLD and NEW from trigger

Mansour Al Akeel <[email protected]> Sat, 6 Jun 2015 15:33:25 +0400
Newsgroups gmane.comp.db.mysql.devel
Message-ID <CAFvvX=bvAYrU=3htH33atftku=qg2MVkfZ0QcuNOWndtNqc9Xw@mail.gmail.com>
In postgres we can use OLD and NEW in a trigger to get hstore values.
I want to get the same values without knowing the fields of  the table
in advance.

Please see https://wiki.postgresql.org/wiki/Audit_trigger_91plus



On Fri, Jun 5, 2015 at 9:27 PM, shawn l.green <[email protected]> wrote:
>
>
> On 6/5/2015 7:53 AM, Mansour Al Akeel wrote:
>>
>> Hello,
>>
>>
>> I am searching the possibility to write a UDF that needs access to all
>> the fields before and after an update of a record.
>> The function needs to convert this record to a CSV.
>>
>> OLD and NEW keywords inside a trigger access the fields values only if
>> they are known in advance.
>> For example (OLD.id). I can not access the whole record or convert it
>> to a CSV as if (OLD.*).
>>
>> Is there a way in mysql to convert the values of a record without
>> knowing its fields name (OLD and NEW) inside a trigger to a CSV ?
>>
>> Thank you.
>>
>
> The OLD and NEW psuedo tables only exist inside of Triggers. To pass those
> values to a function, you need to pass those fields individually as
> parameters.  This should be easy as every trigger is created uniquely per
> table and when you create the trigger you already know the columns on the
> table.
>
> What exactly are you attempting to accomplish with your UDF? There may be
> easier ways to go about it.
>
>
> --
> Shawn Green
> MySQL Senior Principal Technical Support Engineer
> Oracle USA, Inc. - Hardware and Software, Engineered to Work Together.
> Office: Blountville, TN
>
> --
> MySQL Internals Mailing List
> For list archives: http://lists.mysql.com/internals
> To unsubscribe:    http://lists.mysql.com/internals
>

-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals