Re: Dynamic sql example

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

 



2009/11/24 ramasubramanian <ramasubramanian.g@xxxxxxxxxxxxxxxxxx>:
> Dear All.
>     Can any one give me dynamic sql in postgres stored procedure using
> "USING CLAUSE"

CREATE TABLE tab(a integer);

CREATE OR REPLACE FUNCTION foo(_a integer)
RETURNS void AS $$
DECLARE r record;
BEGIN
  FOR r IN EXECUTE 'SELECT * FROM tab WHERE a = $1' USING _a LOOP
    RAISE NOTICE '%', r.a;
  END LOOP;
END;
$$ LANGUAGE plpgsql;

regards
Pavel Stehule



> Regards,
> Ram

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


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux