I am trying to call db2 in C on zos.Actually the program is fetching the data from the table.But it is not printing the output in the printf statement.
Hereby i have given the part of the code.
#include<stdio.h>
.
.
.
{
printf("*** Cursor Declaration ***\n");
EXEC SQL DECLARE C1 CURSOR FOR
SELECT
DEPTNUM
FROM
STDDATA
WHERE
STDID = 10
;
EXEC SQL OPEN C1;
printf("After OPEN Cursor C1 SQLERROR CODE(%d)\n",sqlcode);
printf("Fetch Cursor");
if(sqlca.sqlcode < 0) {return -1;}
EXEC SQL FETCH C1 INTO
:S_DEPTNUM;
returncode = sqlcode;
printf("After FETCH Cursor C1 SQLERROR CODE(%d)\n",sqlcode);
printf("DEPTNUM IS:\n",S_DEPTNUM); <-- error here
printf("\n*** Successful ***\n");
}
.
.
.
{
printf("*** Cursor Declaration ***\n");
EXEC SQL DECLARE C1 CURSOR FOR
SELECT
DEPTNUM
FROM
STDDATA
WHERE
STDID = 10
;
EXEC SQL OPEN C1;
printf("After OPEN Cursor C1 SQLERROR CODE(%d)\n",sqlcode);
printf("Fetch Cursor");
if(sqlca.sqlcode < 0) {return -1;}
EXEC SQL FETCH C1 INTO
:S_DEPTNUM;
returncode = sqlcode;
printf("After FETCH Cursor C1 SQLERROR CODE(%d)\n",sqlcode);
printf("DEPTNUM IS:\n",S_DEPTNUM); <-- error here
printf("\n*** Successful ***\n");
}
S_DEPTNUM is the host variable i declared in the program.
The printf statement which i bolded doesn't display a result.It displays only the statement which is under quotes.Do the printf statement is correct??.
I need that the fetched data should move into the host variables and it is to be displayed in spool.
Kindly please share your views to make the code successful.
Coded