Обсуждение: ECPG: How to use #define and string host variable

Поиск
Список
Период
Сортировка

ECPG: How to use #define and string host variable

От
reply2nelson@yahoo.com (Nelson)
Дата:
I want to declare a character string's
length as a #define and below gives me:

ERROR: parse error, expecting `CVARIABLE' or `ICONST' or `']'' or `'('
' at or near "MAX"


#define MAX 10

EXEC SQL BEGIN DECLARE SECTION;  char t[MAX];
EXEC SQL END DECLARE SECTION;


How do I make the precompiler see the define?

Thanks.


Re: ECPG: How to use #define and string host variable

От
Michael Meskes
Дата:
On Wed, Jan 02, 2002 at 10:22:59AM -0800, Nelson wrote:
> ERROR: parse error, expecting `CVARIABLE' or `ICONST' or `']'' or `'('
> ' at or near "MAX"
> 
> #define MAX 10
> 
> EXEC SQL BEGIN DECLARE SECTION;
>    char t[MAX];
> EXEC SQL END DECLARE SECTION;
> 
> How do I make the precompiler see the define?

Just use 

EXEC SQL DEFINE MAX 10;

EXEC SQL BEGIN DECLARE SECTION;
char t[MAX];
EXEC SQL END DECLARE SECTION;

ECPG only parses statements beginning with EXEC SQL.

Michael
-- 
Michael Meskes
Michael@Fam-Meskes.De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!