pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Johnston <polobo@yahoo.com>
To: 'James Sharrett' <jsharrett@tidemark.net>
To: pgsql-sql@postgresql.org
Subject: Re: returning values to variables from dynamic SQL
Date: Sat, 8 Sep 2012 19:42:42 -0400
Message-ID: <00ea01cd8e1b$a4435630$ecca0290$@yahoo.com> (raw)
In-Reply-To: <CC713DA8.32CC%jsharrett@tidemark.net>
References: <CC713DA8.32CC%jsharrett@tidemark.net>

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
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.






view thread (2+ messages)

Message-ID: <00ea01cd8e1b$a4435630$ecca0290$@yahoo.com>
Permalink:  ../00ea01cd8e1b$a4435630$ecca0290$@yahoo.com/
Also on:    postgresql.org/message-id/00ea01cd8e1b$a4435630$ecca0290$@yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: polobo@yahoo.com, jsharrett@tidemark.net
  Subject: Re: returning values to variables from dynamic SQL
  In-Reply-To: <00ea01cd8e1b$a4435630$ecca0290$@yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox