How to reference C function parameters from embedded SQL

From: "Dick Brooks" <dick(at)8760(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: How to reference C function parameters from embedded SQL
Date: 2001-06-15 15:43:57
Message-ID: NDBBIOBLMLCDOHCHIKMGAEHEGAAA.dick@8760.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 parameter names 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
without having to declare them first?

Thanks in advance,

Dick Brooks
Group 8760
110 12th Street North
Birmingham, AL 35203
dick(at)8760(dot)com
205-250-8053
Fax: 205-250-8057
http://www.8760.com/

InsideAgent - Empowering e-commerce solutions

In response to

  • CLUSTER. at 2001-06-15 14:59:23 from Dariusz Pietrzak

Browse pgsql-general by date

  From Date Subject
Next Message Dariusz Pietrzak 2001-06-15 15:49:16 Re: CLUSTER. (fwd)
Previous Message Thalis A. Kalfigopoulos 2001-06-15 15:42:04 Re: CLUSTER. (fwd)