RE: Does PostgreSQL support Dynamic SQL? - Mailing list pgsql-general

From Mike Mascari
Subject RE: Does PostgreSQL support Dynamic SQL?
Date
Msg-id 01C07E7F.AF09B810.mascarm@mascari.com
Whole thread Raw
In response to Does PostgreSQL support Dynamic SQL?  ("Lark" <litr@beer.com>)
Responses Re: Does PostgreSQL support Dynamic SQL?
List pgsql-general
Its an extension to the embedded SQL preprocessor which allows you to
dynamically build queries at run-time, instead of compile-time. So instead
of having to declare the variables associated with query results at
comile-time, like:

EXEC SQL BEGIN DECLARE SECTION;
    VARCHAR userid[30];
    VARCHAR password[30];
    VARCHAR employee[30];
    ...
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE SQLCA;

and later performing a SELECT statement already defined in the C code like:

EXEC SQL SELECT employeeid
    INTO :employee
    FROM employees;

you can *dynamically* build a SELECT statement, ask the database for a
description of the result sets' attributes, allocate the variables
dynamically to hold the results, and then perform the FETCH.
According to the man page for ecpg with version 7, there currently isn't
support for the PREPARE statement, which is a prerequisite (along with
DESCRIBE) for dynamic SQL queries. Perhaps Michael Meskes might be able to
shed some more light on the status...

Hope that helps,

Mike Mascari
mascarm@mascari.com

-----Original Message-----
From:    The Hermit Hacker [SMTP:scrappy@hub.org]

Stupid question, but what is Dynamic SQL? :)


On Sun, 14 Jan 2001, Lark wrote:

> Hi all!
> 2 questions:
> Does PostgreSQL support dynamic SQL, if so, when can i see any documents
on
> it at PostgreSQL.org?
> thank's :)
>
>
>

Marc G. Fournier                   ICQ#7615664               IRC Nick:
Scrappy
Systems Administrator @ hub.org
primary: scrappy@hub.org           secondary:
scrappy@{freebsd|postgresql}.org


pgsql-general by date:

Previous
From: Chris Ian Capon Fiel
Date:
Subject: Re: VB and PostgreSQL
Next
From: Tom Lane
Date:
Subject: Re: Does PostgreSQL support Dynamic SQL?