how should you define a struct within EXEC SQL section? - Mailing list pgsql-hackers

From bayard kohlhepp
Subject how should you define a struct within EXEC SQL section?
Date
Msg-id 382C8AF5.D4EEFBD6@crosslink.net
Whole thread Raw
List pgsql-hackers
i tried posting this to other groups, as well as searching the archives,

and came up with nothing.

i am using 6.5.2/Mandrake(RedHat)linux 6.0/pentium. i am trying to port
an existing informix 7 web application to postgresql. all of the CGI
programs use embedded SQL. they all use constructs of the form:
...
EXEC SQL BEGIN DECLARE SECTION;
struct user {        /* 40 or 50 or 80 fields... */      int x;      ...
};
EXEC SQL END DECLARE SECTION;

func1(struct user *x,...);
func2(struct user *X, ...);

main()
{   EXEC SQL BEGIN DECLARE SECTION;       struct user user_rec;   EXEC SQL END DECLARE SECTION;

...
}

ecpg doesn't recognize (ie, "parse error") struct declarations that
occurred outside of the current BEGIN/END section. that forces me to
redeclare the entire struct definition with every variable declaration.
i have gone through and exploded all the declarations to do that, but
now ecpg dies with a segmentation fault, does not report a line number,
and erases the .c in the process so i can't tell how far it got (i
experimented with 2 and 3 field structs, and it worked okay, but some of

these structs have 140+ fields).

what is the proper solution for defining a database record structure,
then declaring variables that use that definition within EXEC SQL
sections?





pgsql-hackers by date:

Previous
From: bayard kohlhepp
Date:
Subject: how to handle struct within EXEC SQL DECLARE SECTION?
Next
From: Hannu Krosing
Date:
Subject: Re: [HACKERS] compression in LO and other fields