Hi all;
I have problems compiling the following file which includes Exec SQL..
Does anybody out there know what causes this error?
Thanks a lot
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlenv.h>
#include <sqlcodes.h>
#include <time.h>
#define EXIT 0
#define NOEXIT 1
/*----------------------------------------------------------------------------
Include DB2's SQL error reporting facility.
----------------------------------------------------------------------------*/
EXEC SQL INCLUDE SQLCA ;
/*----------------------------------------------------------------------------
Declare the SQL interface variables.
----------------------------------------------------------------------------*/
EXEC SQL BEGIN DECLARE SECTION ;
short sage;
short sid;
char sname[16];
EXEC SQL END DECLARE SECTION ;
/*----------------------------------------------------------------------------
Declare variables to be used in the following C program.
----------------------------------------------------------------------------*/
char msg[1025];
int rc;
int errcount;
/*----------------------------------------------------------------------------
.....
.....
main (int argc, char *argv[])
{
/* Grab the first command argument. This is the SID. */
if (argc > 1) {
sid = atoi(argv[1]);
printf("SID requested is %d.\n", sid);
/* If there is no arguement, bail. */
} else {
printf("Which SID?\n");
exit(0);
}
EXEC SQL CONNECT TO GO3421;
CHECK_SQL(0, "Connect failed", EXIT);
/* Find the name and age of sailor SID. */
EXEC SQL SELECT SNAME, AGE into :sname, :sage
FROM TECHSTU.SAILOR
WHERE sid = :sid;
CHECK_SQL(0, "The SELECT query failed.", EXIT);
/* Report the age. */
printf("Sailor %s's age is %d.\n", sname, sage);
printf("Executed Successfuly\n") ;
printf("Bye\n") ;
errorexit:
EXEC SQL CONNECT RESET;
}
Errors:
--------------------------------------------------------
Compiling...
test2.c
D:\SQL_C\myproject\test2.c(30) : error C2282: 'EXEC' is followed by 'SQL' (missing ','?)
D:\SQL_C\myproject\test2.c(36) : error C2282: 'EXEC' is followed by 'SQL' (missing ','?)
D:\SQL_C\myproject\test2.c(40) : error C2282: 'EXEC' is followed by 'SQL' (missing ','?)
D:\SQL_C\myproject\test2.c(125) : error C2065: 'EXEC' : undeclared identifier
D:\SQL_C\myproject\test2.c(125) : error C2146: syntax error : missing ';' before identifier 'SQL'
D:\SQL_C\myproject\test2.c(125) : error C2065: 'SQL' : undeclared identifier
D:\SQL_C\myproject\test2.c(125) : error C2146: syntax error : missing ';' before identifier 'CONNECT'
D:\SQL_C\myproject\test2.c(125) : error C2065: 'CONNECT' : undeclared identifier
D:\SQL_C\myproject\test2.c(125) : error C2146: syntax error : missing ';' before identifier 'TO'
D:\SQL_C\myproject\test2.c(125) : error C2065: 'TO' : undeclared identifier
D:\SQL_C\myproject\test2.c(125) : error C2146: syntax error : missing ';' before identifier 'GO3421'
D:\SQL_C\myproject\test2.c(125) : error C2065: 'GO3421' : undeclared identifier
D:\SQL_C\myproject\test2.c(126) : error C2065: 'sqlca' : undeclared identifier
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlcode' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct sqlca *'
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlcode' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlcaid' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlcabc' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlcode' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlerrml' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlerrmc' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlerrp' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlerrd' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlerrd' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlerrd' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlerrd' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlerrd' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlerrd' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlwarn' must have struct/union type
D:\SQL_C\myproject\test2.c(126) : error C2224: left of '.sqlstate' must have struct/union type
D:\SQL_C\myproject\test2.c(129) : error C2146: syntax error : missing ';' before identifier 'SQL'
D:\SQL_C\myproject\test2.c(129) : error C2146: syntax error : missing ';' before identifier 'SELECT'
D:\SQL_C\myproject\test2.c(129) : error C2065: 'SELECT' : undeclared identifier
D:\SQL_C\myproject\test2.c(129) : error C2146: syntax error : missing ';' before identifier 'SNAME'
D:\SQL_C\myproject\test2.c(129) : error C2065: 'SNAME' : undeclared identifier
D:\SQL_C\myproject\test2.c(129) : error C2065: 'AGE' : undeclared identifier
D:\SQL_C\myproject\test2.c(129) : error C2146: syntax error : missing ';' before identifier 'into'
D:\SQL_C\myproject\test2.c(129) : error C2059: syntax error : ':'
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlcode' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : warning C4133: 'function' : incompatible types - from 'int *' to 'struct sqlca *'
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlcode' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlcaid' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlcabc' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlcode' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlerrml' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlerrmc' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlerrp' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlerrd' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlerrd' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlerrd' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlerrd' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlerrd' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlerrd' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlwarn' must have struct/union type
D:\SQL_C\myproject\test2.c(133) : error C2224: left of '.sqlstate' must have struct/union type
D:\SQL_C\myproject\test2.c(142) : error C2146: syntax error : missing ';' before identifier 'SQL'
D:\SQL_C\myproject\test2.c(142) : error C2146: syntax error : missing ';' before identifier 'CONNECT'
D:\SQL_C\myproject\test2.c(142) : error C2146: syntax error : missing ';' before identifier 'RESET'
D:\SQL_C\myproject\test2.c(142) : error C2065: 'RESET' : undeclared identifier
D:\SQL_C\myproject\test2.c(143) : warning C4035: 'main' : no return value
Error executing cl.exe.
test2.obj - 57 error(s), 3 warning(s)