2009/11/9 Yadira Lizama Mue <ylizama(at)uci(dot)cu>:
>
> Hi,
> I have a function which receive a parameters as text. This text is a query. I want to execute this query, but I don't know how. Can any one help me?
> Regards,
> Yadira
>
>
> CREATE OR REPLACE FUNCTION myfunction(text)
> RETURNS void AS
> $BODY$
> --I want execute the text I pass by parameters as a query.
> $BODY$
> LANGUAGE 'sql' VOLATILE
>
You can use EXECUTE
(http://www.postgresql.org/docs/8.4/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN)
Out of curiosity, why would you wish to do such a thing?
Regards
Thom