Search Postgresql Archives

Re: Dynamic binding in plpgsql function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 resulting value 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@xxxxxxxxxxxxxxxx
Blog:http://vibhork.blogspot.com


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux