Re: returning values to variables from dynamic SQL - Mailing list pgsql-sql

From David Johnston
Subject Re: returning values to variables from dynamic SQL
Date
Msg-id 00ea01cd8e1b$a4435630$ecca0290$@yahoo.com
Whole thread Raw
In response to returning values to variables from dynamic SQL  (James Sharrett <jsharrett@tidemark.net>)
List pgsql-sql
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]
On Behalf Of James Sharrett
Sent: Saturday, September 08, 2012 6:24 PM
To: pgsql-sql@postgresql.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.





pgsql-sql by date:

Previous
From: James Sharrett
Date:
Subject: returning values to variables from dynamic SQL
Next
From: JORGE MALDONADO
Date:
Subject: Query with LIMIT clause