ecpg & host variables

From: Daniel Kelley <dkelley(at)otec(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: ecpg & host variables
Date: 2002-07-19 21:02:53
Message-ID: Pine.BSF.4.20L2.0207191555500.34939-100000@mx1.gc.ny.otec.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces


hi-

i'm looking to convert a pro*c application to something
postgresql-based. i've just started to experiment with ecpg, and have
been pleasantly surprised that large parts of out existing code will be
useable without too much alteration.

the problems that i've run into all involve variable declarations. we
have a large number of complex structures that map in-house
datatypes. with oracle, we could do something like this:

--------------------------------------------------------
typedef struct {
int id;
char name[30];
char dsc[1000];
} rec_t;

rec_t r;

EXEC SQL SELECT
id,
name,
dsc
INTO
:r.id,
:r.name,
:r.dsc
FROM table
WHERE id = :r.id;
--------------------------------------------------------

to make this code work with ecpg, i've made the following changes:

--------------------------------------------------------
EXEC SQL BEGIN DECLARE SECTION;
typedef struct {
int id;
char name[30];
char dsc[1000];
} rec_t;

rec_t r;
EXEC SQL END DECLARE SECTION;
--------------------------------------------------------

which yields the following error from ecpg:

postgres.pgc:15: ERROR: invalid datatype 'typedef'

is there are facility that i might be missing that would allow me to use
our existing structures as host variables w/ postgres embedded sql? or am
i better off just skipping ecpg and coding directly with libpq?

thanks in advance for any insight you can offer.

dan

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Tom Lane 2002-07-19 21:24:28 Re: ecpg & host variables
Previous Message Joe Conway 2002-07-18 17:21:36 Re: bytea on windows perl client