Re: Dynamic sql example

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: ramasubramanian <ramasubramanian(dot)g(at)renaissance-it(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Dynamic sql example
Date: 2009-11-24 12:42:33
Message-ID: 162867790911240442w54e16b1cn612b666c4105bf9f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

2009/11/24 ramasubramanian <ramasubramanian(dot)g(at)renaissance-it(dot)com>:
> 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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Luca Tettamanti 2009-11-24 13:37:08 DELETE performance problem
Previous Message ramasubramanian 2009-11-24 11:25:56 Dynamic sql example