Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.postgresql > #110

Re: Stored procedure and dynamic statements?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.erje.net!newsfeed.utanet.at!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail
From "Laurenz Albe" <invite@spam.to.invalid>
Newsgroups comp.databases.postgresql
References <b8beed02-7fe4-4ac8-90b9-7a65860ed0e0@v16g2000vbq.googlegroups.com>
Subject Re: Stored procedure and dynamic statements?
Date Tue, 3 May 2011 10:04:05 +0200
X-Priority 3
X-MSMail-Priority Normal
X-Newsreader Microsoft Outlook Express 6.00.2900.5931
X-RFC2646 Format=Flowed; Original
X-MimeOLE Produced By Microsoft MimeOLE V6.00.2900.6090
Organization dienste.wien.at ISP
Message-ID <1304409866.536393@proxy.dienste.wien.at> (permalink)
X-Cache nntpcache 2.3.3 (see http://www.nntpcache.org/)
Lines 27
NNTP-Posting-Host 141.203.254.23
X-Trace 1304409868 aconews.univie.ac.at 34944 141.203.254.23
X-Complaints-To abuse@univie.ac.at
Xref x330-a1.tempe.blueboxinc.net comp.databases.postgresql:110

Show key headers only | View raw


durumdara wrote:
> I want to ask that is pg supports dynamic usage of SQL, or variable as
> SQL (or part of SQL) statement?
>
> :tablename = call CreateTempTable;
> insert into :tablename ....
> drop table :tablename
>
> or (FireBird like cursor handling):
>
> sql = "select * from " || :tablename || " where..."
> for select :sql ....
> ...

SQL itself does not support that, but there are things like that
in psql:

\set varname value
CREATE TABLE :varname (id integer);
INSERT INTO :varname VALUES (1);

Does that help?

Yours,
Laurenz Albe 

Back to comp.databases.postgresql | Previous | Next | Find similar


Thread

Re: Stored procedure and dynamic statements? "Laurenz Albe" <invite@spam.to.invalid> - 2011-05-03 10:04 +0200

csiph-web