| From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
|---|---|
| To: | Juan Luis Echeverria <juanluise(at)usa(dot)net> |
| Cc: | pgsql-es-ayuda(at)postgresql(dot)org |
| Subject: | Re: Variable NEW en una funcion para un trigger |
| Date: | 2008-05-02 17:35:26 |
| Message-ID: | 20080502173526.GM2320@alvh.no-ip.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-es-ayuda |
Juan Luis Echeverria escribió:
> Solicito me aclaren una duda porfavor: Tengo un trigger BEFORE INSERT FOR
> EACH ROW y en la funcion (con PL/pgSQL Postgresql 8.1) que usa en una de sus
> lineas tiene la siguiente instruccin:
>
> NEW.idsync008 = new_sync;
>
> en donde idsync008 es un campo de la tabla afectada por el trigger. Esta
> instruccin funciona pero la quiero sustituir por esta otra
>
> EXECUTE 'NEW.' || trim(both '' from idsyncxxx) || ' = ' ||
> new_idsync || ';';
>
> En donde syncxxx es una variable que ser ercibe como argumento en la funcion
> y que contiene el valor 'idsync008'.
No se puede hacer esto en PL/pgSQL.
Puedes escribir tu funcion en PL/Perl y funcionar.
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fernando Moreno | 2008-05-02 17:50:00 | Re: Variable NEW en una funcion para un trigger |
| Previous Message | Juan Luis Echeverria | 2008-05-02 16:40:05 | Variable NEW en una funcion para un trigger |