informix与unix
/*
文件: MyInfPro.ec
*/
#include <stdio.h>
#include <sqlca.h>
#include <sqlda.h>
#include <sqltypes.h>
#include <sqlstype.h>
main()
{
EXEC SQL INCLUDE SQLCA; // notice
EXEC SQL BEGIN DECLARE SECTION;
char *string1;
char str1[ 10 ];
char str2[ 10 ];
EXEC SQL END DECLARE SECTION;
EXEC SQL CREATE DATABASE example1;
sleep(10);
DATABASE example1;
if( SQLCODE == SUCCESS )
{
EXEC SQL CREATE TABLE Student
(
alarm char(6),
sname char(10)
);
}
EXEC SQL INSERT INTO Student VALUES( "aaa", "aaa");
EXEC SQL INSERT INTO Student VALUES( "bbb", "bbb");
EXEC SQL INSERT INTO Student VALUES( "ccc", "ccc");
EXEC SQL DECLARE fet_cur CURSOR FOR
SELECT alarm, sname FROM Student;
EXEC SQL OPEN fet_cur;
printf( "SQLCODE %d", SQLCODE );
for(;;)
{
memset( str1, 0x00, sizeof( str1 ) );
memset( str2, 0x00, sizeof( str2 ) );
EXEC SQL FETCH fet_cur INTO :str1, :str2;
if( SQLCODE != SUCCESS )
{
printf( "Line %d, SQLCODE = %d ", __LINE__, SQLCODE );
break;
}
printf( " alarm = %s , sname = %s ", str1, str2 );
}
EXEC SQL CLOSE fet_cur;
EXEC SQL CLOSE DATABASE;
return 0;
}
ykt> esql MyInfPro.ec
提示的错误信息:
esqlc: "MyInfPro.ec", line 23: Error -33051: Syntax error on identifier or symbol 'example'.
[解决办法]
我试了下,报的不是这个错。我的编译环境下需要如下变动:
增加如下
#define SUCCESS 0
修改如下
DATABASE example1;
改为
EXEC SQL DATABASE example1;
然后编译通过了。
我是HP-UX 11v3+informix9.4
[解决办法]