Re: Dynamic binding in plpgsql function - Mailing list pgsql-general

From Vibhor Kumar
Subject Re: Dynamic binding in plpgsql function
Date
Msg-id 576FF187-6925-4984-9702-42FE1C9296FC@enterprisedb.com
Whole thread Raw
In response to Dynamic binding in plpgsql function  (Pierre Racine <Pierre.Racine@sbf.ulaval.ca>)
Responses Re: Dynamic binding in plpgsql function  (Pierre Racine <Pierre.Racine@sbf.ulaval.ca>)
List pgsql-general
On Mar 2, 2011, at 4:31 AM, Pierre Racine wrote:

> CREATE OR REPLACE FUNCTION ST_MyGeneralFunction(callback text)
>    RETURNS SETOF geomval AS $$
>    DECLARE
>        x integer;
>        y integer;
>    BEGIN
>        y := somecalculation;
>        x := 'callback'(y);  --This is what I need
>        RETURN x;
>    END;
>    $$ LANGUAGE 'plpgsql';
>
> I don't want to do an EXECUTE statement since I have no table to put after the FROM clause. I want to assign the
resultingvalue directly to a variable like in my example. 


You don't need any table to assign value of function to Variable, if function returning single value. You can use
EXECUTE'SELECT '||$1||'(y)' into x; 

Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
vibhor.kumar@enterprisedb.com
Blog:http://vibhork.blogspot.com


pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Dynamic binding in plpgsql function
Next
From: Royce Ausburn
Date:
Subject: Query should have failed, but didn't?