Some basic ecpg questions

From: "Murphy Pope" <pope_murphy(at)hotmail(dot)com>
To: <pgsql-interfaces(at)postgresql(dot)org>
Subject: Some basic ecpg questions
Date: 2002-03-21 00:08:28
Message-ID: OE361Dhx6t1W7Bzqc6H0000ce66@hotmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

(I apologize in advance for such basic questions, but...)

I saw in some of the test sources for ecpg that I can use the
EXEC SQL TYPE foo IS int;
statement to tell ecpg about an artificial data type. I also noticed that I can use EXEC SQL TYPE to tell ecpg about structures. But I have a few questions about this:

1) It looks like I have to define each data type twice: once for ecpg and once for C. Is that correct or is there something basic that I am missing?

2) I could not seem to include a varchar inside of a struct - the ecpg preprocessor got confused by that. My construct looked something like:

typedef struct
{
int id;
varchar data[50];
} foo;

EXEC SQL TYPE foo IS
struct
{
int id;
varchar data[50];
};

When I tried to declare a 'foo' inside of the DECLATION SECTION, ecpg seemed to produce some code that my GNU CC didn't understand. (If it would help, I can send in the actual source and resulting .c file).

3) If I use EXEC SQL TYPE to declare a structure, it doesn't look like I can use an array of these structures to retreive multiple rows. Using the previous example structures, I want to do something like:

EXEC SQL BEGIN DECLARATION SECTION;
foo records[5];
EXEC SQL END DECLARATION SECTION;

EXEC SQL select * into :records from bar limit 5;

ecpg doesn't seem to understand this construct, but if I take members out of the structure and declare them as:

EXEC SQL BEGIN DECLARATION SECTION;
int id[5];
char data[5][50];
EXEC SQL END DECLARATION SECTION;

that works (yes, I know I changed from varchar to char in this example).

I am using ecpg (and postgresql) version 7.1.3.

Thanks in advance for any help.

-- Murphy

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Michael Meskes 2002-03-21 09:37:58 typedef patches for ecpg
Previous Message Nicolas Bazin 2002-03-20 23:21:08 Re: ecpg weird behavior