Re: Execute a query passed by parameters to a function - Mailing list pgsql-general

From Thom Brown
Subject Re: Execute a query passed by parameters to a function
Date
Msg-id bddc86150911090800y61c5a4c0je007f712b7609f2c@mail.gmail.com
Whole thread Raw
In response to Execute a query passed by parameters to a function  (Yadira Lizama Mue <ylizama@uci.cu>)
Responses Re: Execute a query passed by parameters to a function  (Yadira Lizama Mue <ylizama@uci.cu>)
List pgsql-general
2009/11/9 Yadira Lizama Mue <ylizama@uci.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
knowhow. 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

pgsql-general by date:

Previous
From: Alexandra Roy
Date:
Subject: Re: PostgreSQL 8.3.8 on AIX5.3 : compilation failed
Next
From: Chris Barnes
Date:
Subject: Re: Looking for a script that performs full online backup of postgres in archive mode