character array but
is not initialised,(memset
) , that might be an issue! Also check for the Indicator variable status as a good practice.
The ROWNUM
in the query I added is not needed if record_id_num
is PrimaryKey. but still anyone who read the code, might get a doubt, what if the query returns more than one row. In that case SQLCODE
-2112
should be handled.
char buf[19+1];
short i_modified_time = -1;
memset(buf,'\0',sizeof(buf);
EXEC SQL SELECT TO_CHAR( modified_time, 'YYYY-MM-DD HH24:MI:SS')
INTO :buf :i_modified_time
FROM RECORD_ENTRY_TABLE
WHERE record_id_num = rec_id_num
AND ROWNUM < 2;
if(i_modified_time == 0) {
printf("THe modified time is: <%s>", buf);
}else if(sqlca.sqlcode != 0){
printf("Error while Query <%s>",sqlca.sqlerrm);
}else {
printf("THe modified time is not available);
}