| From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
|---|---|
| To: | "jvenegasperu (dot)" <jvenegasperu(at)gmail(dot)com> |
| Cc: | Ayuda <pgsql-es-ayuda(at)postgresql(dot)org> |
| Subject: | Re: acceso a FOR con tablas como parametros |
| Date: | 2013-11-21 23:12:27 |
| Message-ID: | 20131121231227.GG6041@eldon.alvh.no-ip.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-es-ayuda |
jvenegasperu . escribió:
> HOLA
>
> tengo esta linea en una funcion en postgres
>
> for rec in select * from *tmp_cargas* where id = $2 loop
>
> como hago para que tmp_cargas sea una parametro de la funcion y pueda
> interpretarse algo como
>
> for rec in select * from $1 where id = $2 loop
Necesitas usar EXECUTE,
FOR .. IN EXECUTE 'select .. ' LOOP
-- algo
END LOOP
http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-RECORDS-ITERATING
(busca FOR-IN-EXECUTE).
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
-
Enviado a la lista de correo pgsql-es-ayuda (pgsql-es-ayuda(at)postgresql(dot)org)
Para cambiar tu suscripción:
http://www.postgresql.org/mailpref/pgsql-es-ayuda
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2013-11-21 23:15:18 | Re: duda sobre indices y llaves foráneas |
| Previous Message | Alvaro Herrera | 2013-11-21 23:04:57 | Re: Una de Transacciones |