I am using following codes to get the accountname, and account from the
Table Account;
accountname, and account are varchar(30) and it can be null.
The code has no problem when both accountname, and account are not
null. It gives me an errror code of -209 when the account is null.
Anyone has any idea of fixing it.
the output looks like :
error in fetch -209
Thanks,
EXEC SQL BEGIN DECLARE SECTION;
char query_string[256];
char name[30];
char account[30];
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT TO :dbname user :userid/:passwd;
if(sqlca.sqlcode) {
printf("error in connect\n");
return FALSE;
}
sprintf(query_string, "SELECT accountname, account FROM Account where
AccountID = %d", customerId);
EXEC SQL PREPARE sql_command FROM :query_string;
EXEC SQL DECLARE c_cursor2 CURSOR FOR sql_command;/* DECLARE a cursor
*/
EXEC SQL OPEN c_cursor2;
if(sqlca.sqlcode) {
printf("error in cursor\n");
return FALSE;
}
EXEC SQL FETCH c_cursor2 INTO :name, :account;
if(sqlca.sqlcode) {
printf("error in fetch %d\n", sqlca.sqlcode);
return FALSE;
}