From: Pavel Stehule on
2010/3/9 strk <strk(a)keybit.net>:
> How can a pl/pgsql trigger change the
> values of dynamic fields in NEW record ?
>
> By "dynamic" I mean that the field name
> is a variable in the trigger context.
>
> I've been told it's easy to do with pl/perl but
> I'd like to delive a pl/pgsql solution to have
> less dependencies.

It isn't possible yet

regards
Pavel Stehule

>
> Thanks in advance.
>
> --strk;
>
>  ()   Free GIS & Flash consultant/developer
>  /\   http://strk.keybit.net/services.html
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: strk on
On Tue, Mar 09, 2010 at 06:59:31PM +0100, Pavel Stehule wrote:
> 2010/3/9 strk <strk(a)keybit.net>:
> > How can a pl/pgsql trigger change the
> > values of dynamic fields in NEW record ?
> >
> > By "dynamic" I mean that the field name
> > is a variable in the trigger context.
> >
> > I've been told it's easy to do with pl/perl but
> > I'd like to delive a pl/pgsql solution to have
> > less dependencies.
>
> It isn't possible yet

Any workaround you may suggest ?

--strk;

() Free GIS & Flash consultant/developer
/\ http://strk.keybit.net/services.html

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Pavel Stehule on
2010/3/9 strk <strk(a)keybit.net>:
> On Tue, Mar 09, 2010 at 06:59:31PM +0100, Pavel Stehule wrote:
>> 2010/3/9 strk <strk(a)keybit.net>:
>> > How can a pl/pgsql trigger change the
>> > values of dynamic fields in NEW record ?
>> >
>> > By "dynamic" I mean that the field name
>> > is a variable in the trigger context.
>> >
>> > I've been told it's easy to do with pl/perl but
>> > I'd like to delive a pl/pgsql solution to have
>> > less dependencies.
>>
>> It isn't possible yet
>
> Any workaround you may suggest ?

I don't know it - use C language maybe.

Pavel

>
> --strk;
>
>  ()   Free GIS & Flash consultant/developer
>  /\   http://strk.keybit.net/services.html
>

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: hubert depesz lubaczewski on
On Tue, Mar 09, 2010 at 06:59:31PM +0100, Pavel Stehule wrote:
> 2010/3/9 strk <strk(a)keybit.net>:
> > How can a pl/pgsql trigger change the
> > values of dynamic fields in NEW record ?
> >
> > By "dynamic" I mean that the field name
> > is a variable in the trigger context.
> >
> > I've been told it's easy to do with pl/perl but
> > I'd like to delive a pl/pgsql solution to have
> > less dependencies.
>
> It isn't possible yet

well, it's possible. it's just not nice.

http://www.depesz.com/index.php/2010/03/10/dynamic-updates-of-fields-in-new-in-plpgsql/

depesz

--
Linkedin: http://www.linkedin.com/in/depesz / blog: http://www.depesz.com/
jid/gtalk: depesz(a)depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

From: Andrew Dunstan on


hubert depesz lubaczewski wrote:
> On Tue, Mar 09, 2010 at 06:59:31PM +0100, Pavel Stehule wrote:
>
>> 2010/3/9 strk <strk(a)keybit.net>:
>>
>>> How can a pl/pgsql trigger change the
>>> values of dynamic fields in NEW record ?
>>>
>>> By "dynamic" I mean that the field name
>>> is a variable in the trigger context.
>>>
>>> I've been told it's easy to do with pl/perl but
>>> I'd like to delive a pl/pgsql solution to have
>>> less dependencies.
>>>
>> It isn't possible yet
>>
>
> well, it's possible. it's just not nice.
>
> http://www.depesz.com/index.php/2010/03/10/dynamic-updates-of-fields-in-new-in-plpgsql/
>

Using an hstore in 9.0 it's not too bad, Try something like:

CREATE OR REPLACE FUNCTION dyntrig()
RETURNS trigger
LANGUAGE plpgsql
AS $function$

declare
hst hstore;
begin
hst := hstore(NEW);
hst := hst || ('foo' => 'bar');
NEW := populate_record(NEW,hst);
return NEW;
end;

$function$;


But this question probably belongs on -general rather than -hackers.

cheers

andrew



--
Sent via pgsql-hackers mailing list (pgsql-hackers(a)postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers