The Compile/link/bind/run of the C program with DB has been successfully executed and a output file has been generated. This file displays only the mentioned printf statements. In this scenario it is not showing any sqlcode too.
The same program gives a Sqlcode when the compilation fails.
For eg: I tried executing the code by calling database name. And got sql code -84 (UNACCEPTABLE SQL CODE).
I am attaching respective code with this for your review. Kindly suggest me the ways to get the proper output.
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
EXEC SQL INCLUDE SQLCA;
EXEC SQL INCLUDE SQLDA;
EXEC SQL BEGIN DECLARE SECTION;
char e_empdept??(3??);
EXEC SQL DECLARE C1 CURSOR FOR
SELECT EMPDEPT FROM tablename
WHERE ID = 10;
EXEC SQL END DECLARE SECTION;
int main(int argc,char *argv??(??))
{
printf("*** BEGIN OF PROGRAM *** \n");
EXEC SQL OPEN C1;
printf("SQL ERROR CODE: \n",SQLCODE);
while (SQLCODE==0)
{
EXEC SQL FETCH C1 INTO :e_empdept;
}
EXEC SQL CLOSE C1;
printf("The EMP DEPT IS: \n", e_empdept);
return 0;
#include <string.h>
#include <stdio.h>
#include <ctype.h>
EXEC SQL INCLUDE SQLCA;
EXEC SQL INCLUDE SQLDA;
EXEC SQL BEGIN DECLARE SECTION;
char e_empdept??(3??);
EXEC SQL DECLARE C1 CURSOR FOR
SELECT EMPDEPT FROM tablename
WHERE ID = 10;
EXEC SQL END DECLARE SECTION;
int main(int argc,char *argv??(??))
{
printf("*** BEGIN OF PROGRAM *** \n");
EXEC SQL OPEN C1;
printf("SQL ERROR CODE: \n",SQLCODE);
while (SQLCODE==0)
{
EXEC SQL FETCH C1 INTO :e_empdept;
}
EXEC SQL CLOSE C1;
printf("The EMP DEPT IS: \n", e_empdept);
return 0;