Re: Use of C function parameters from embedded SQL - Mailing list pgsql-general

From Michael Meskes
Subject Re: Use of C function parameters from embedded SQL
Date
Msg-id 20010621091104.A4208@feivel.credativ.de
Whole thread Raw
In response to Use of C function parameters from embedded SQL  ("Dick Brooks" <dick@8760.com>)
Responses Authentification  (tillea@rki.de)
List pgsql-general
On Thu, Jun 14, 2001 at 02:16:29PM -0500, Dick Brooks wrote:
> Here is a section of embedded SQL code that works fine in Oracle (some code
> removed for brevity):
>
> void open_database(char *user_name, char*pass_word)
> {
> EXEC SQL CONNECT :user_name IDENTIFIED BY :pass_word;
> }

This only work with Pro*C if you run it in full parse mode. That means Pro*C
will parse your complete C file an not just the EXEC SQL parts. I would not
recommend doing this. At first glance it looks like a nice feature but you
can run into numerous sorts of trouble.

> The only way I could get ecpg to process this code was to include a DECLARE
> section, for example:

Yes, that's the standard way of doing this.

> Does anyone know of a workaround to allow use of the function parameters
> with having to declare them first?

No, there is none. The full parse mode has been on my todo list for a long
time but with very low priority. Sorry.

Michael

--
Michael Meskes
Michael@Fam-Meskes.De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Problems with pgsql 7.1.2 and ExecEvalExpr
Next
From: "Richard Huxton"
Date:
Subject: Re: Hardware Config