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


Groups > comp.databases.postgresql > #110

Re: Stored procedure and dynamic statements?

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 2011-05-03 10:04 +0200
Organization dienste.wien.at ISP
Message-ID <1304409866.536393@proxy.dienste.wien.at> (permalink)

Show all headers | 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