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

From Dick Brooks
Subject Use of C function parameters from embedded SQL
Date
Msg-id 9gb2ld$kf$1@news.tht.net
Whole thread Raw
Responses Re: Use of C function parameters from embedded SQL  (Michael Meskes <meskes@postgresql.org>)
List pgsql-general
I'm in the process of converting some embedded SQL code from ORACLE to
PostgreSQL and I'm running into some snags. I'm wondering if there is an
easy way to use the parameters passed to a C function as variables in a EXEC
SQL command without having to declare the parameter names in a EXEC SQL
DECLARE section.

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;
}

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

void open_database(char *user_name, char*pass_word)
{
EXEC SQL BEGIN DECLARE SECTION;
char *user_name;
char *pass_word;
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT :user_name IDENTIFIED BY :pass_word;
}

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

Thanks in advance,

Dick Brooks



pgsql-general by date:

Previous
From: Raoul Callaghan
Date:
Subject: this is a "If update confirmed, commit, else rollback" question.
Next
From: junkboy@zeus.bwh.harvard.edu (holtzman)
Date:
Subject: Re: What do you do when...? A schema Question