Re:ESQL/C : Syntax Error
Posted in 1999
Chris, Art ; Thanks for your suggestions!
I tried declaring the structure and the cursor before
connecting to the database , still it errors on the
same spot: 'from' unexpected .
Anything else I can try to make it work ?!
Thanks - Maria
Subject: Re: ESQL/C : Syntax error
Oooooo That's an esotheric one. Read on and I shall
enlighten:
Maria Seagull wrote:
Hi,
I am a beginner at ESQL/C, in the first program I've
tried
I have got an syntax error which I
am not able to debug.
It is a simple program .
It uses a cursor and a structure to copy selected rows
from table abcde
to table abcd.
Any help /hints are welcome and appreciated.My
apologies if it is too dumb :)
Thanks - Maria
Informix -Online Version 7.23.UC1
The Error:
##########
Syntax error at line 22 : 'from ' unexpected
##################################################
The Program:
############
#include <stdio.h>
#define ON 1
#define OFF 0
main()
{
Function level declarations, in C, belong at the
beginning of the function (main) before any executable
code. The next line (connect) is generated as an
executable function call so the subsequent structure
definition (struct stc) and variable declaration
(stc01) are illegal syntax where they are. C++
permits definitions and declarations anywhere in the
code but ANSI C permits them ONLY at the beginning of
a statement block (ie immediately following an opening
curly brace and before any executable statements in
the block). Why the error was not caught until the
syntax confusion of the cursor DECLARE below that I do
not know.
EXEC SQL connect to 'newdb';
EXEC SQL BEGIN DECLARE SECTION;
struct stc
{
int v1;
int v2;
int v3;
int v4;
}stc01;
EXEC SQL END DECLARE SECTION;
EXEC SQL declare cur1 cursor for
select a,b,c,d
from abcde
where e = 0;[SNIP]
Art S. Kagel
Hi Maria,
I think you will have to DECLARE your stuff first,
then CONNECT to your database.
Hth,
Chris
__________________________________________________
Do You Yahoo!?
Thousands of Stores. Millions of Products. All in one place.
Yahoo! Shopping: http://shopping.yahoo.com