Re: returning values to variables from dynamic SQL

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'James Sharrett'" <jsharrett(at)tidemark(dot)net>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: returning values to variables from dynamic SQL
Date: 2012-09-08 23:42:42
Message-ID: 00ea01cd8e1b$a4435630$ecca0290$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
From: pgsql-sql-owner(at)postgresql(dot)org [mailto:pgsql-sql-owner(at)postgresql(dot)org]
On Behalf Of James Sharrett
Sent: Saturday, September 08, 2012 6:24 PM
To: pgsql-sql(at)postgresql(dot)org
Subject: [SQL] returning values to variables from dynamic SQL

I have a PG function ( using plpgsql) that calls a number of sub functions
also in plpgsql.  I have two main problems that seem to be variations on the
same theme of running dynamic SQL from a variable with the EXECUTE statement
and returning the results back to a variable defined in the calling
function.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Please read:

http://www.postgresql.org/docs/9.0/interactive/plpgsql-statements.html#PLPGS
QL-STATEMENTS-EXECUTING-DYN

Basically when you use "EXECUTE" you do not embed the "INTO" as part of the
SQL query but rather INTO becomes a modifier of the EXECUTE itself:

EXECUTE 'some query' INTO {variables}

David J.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message JORGE MALDONADO 2012-09-09 17:25:48 Query with LIMIT clause
Previous Message James Sharrett 2012-09-08 22:23:36 returning values to variables from dynamic SQL