主题:C来嵌入SQL语言?急
请问一下,我想用C来嵌入SQL语言,如何实现呢?如下边的代码:
EXEC sql begin declare section;
char no[10];
char name[20];
char sex[2];
int age;
char sd[20];
exec sql end declare section;
long sqlcode ;
exec sql include sqlca;
int main()
{printf("请输入系名:");
scanf("%s",sd);
exec sql connect to test@localhost:54321 user "lkm";
exec sql declare sx for
select *
from student
where sdept=:sd;
exec sql open sx;
for(;;)
{exec sql FETCH sx into :no,:name,:sex,:age,:sd;
if(sqlca.sqlcode!=0)break;
printf("no name sex age sd \n");
printf("%s %s %s %d %s",no,name,sex,sd);
}
exec sql close sx ;
exec sql disconnct test;
}
可在用C编绎器编绎的时候出现很多错误,很多未定义符号,请问一下,是不是得先在SQL中先编绎一下呢?急!
EXEC sql begin declare section;
char no[10];
char name[20];
char sex[2];
int age;
char sd[20];
exec sql end declare section;
long sqlcode ;
exec sql include sqlca;
int main()
{printf("请输入系名:");
scanf("%s",sd);
exec sql connect to test@localhost:54321 user "lkm";
exec sql declare sx for
select *
from student
where sdept=:sd;
exec sql open sx;
for(;;)
{exec sql FETCH sx into :no,:name,:sex,:age,:sd;
if(sqlca.sqlcode!=0)break;
printf("no name sex age sd \n");
printf("%s %s %s %d %s",no,name,sex,sd);
}
exec sql close sx ;
exec sql disconnct test;
}
可在用C编绎器编绎的时候出现很多错误,很多未定义符号,请问一下,是不是得先在SQL中先编绎一下呢?急!