Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-performance by date

Next:From: Luca TettamantiDate: 2009-11-24 13:37:08
Subject: DELETE performance problem
Previous:From: ramasubramanianDate: 2009-11-24 11:25:56
Subject: Dynamic sql example

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group