Can someone help with the issue below please?
I'm trying to redefine the descriptor area and execute a generic insert statement... i'm following Dan's tutorial at...
My code below reference his tutorial under "executing the statement"section...
* sql descriptor area
d t_sqlda ds template
d sqldaid 8
d sqldabc 10i 0
d sqln 5i 0
d sqld 5i 0
//---------------------------------
// SQL Descriptor Redefinition
//---------------------------------
d sqlda ds likeds(t_sqlda) based(sqlda#)
d sqlInpDA ds likeds(t_sqlda) based(sqlInpDA#)
...
g_sqlStmt = 'insert into ' +
%trim(g_libFile) +
' values (' +
%trim(g_valuesList) +
')';
sqlda# = %alloc(%size(sqlda));
sqlInpDA# = %alloc(%size(sqlInpDA));
sqlDA.SQLN = g_fieldArray.count;
//set SQLDABC equal to SQLN*LENGTH(SQLVAR) + 16.
sqlDA.SQLDABC = sqlDA.SQLN * 80 + 16;
//set SQLN and SQLD to the number of parameter markers.
sqlDA.SQLD = sqlDA.SQLN;
exec sql
prepare s1_write FROM :g_sqlStmt;
exec sql
describe input s1_write into :sqlInpDA;
exec sql
execute s1_write using descriptor :sqlInpDA; <-- SQLCODE -804
exec sql
execute immediate :g_sqlStmt;
My error is occurring at the -804 sqlcode noted above...
PREPARE of statement S1_WRITE completed.
DESCRIBE of prepared statement S1_WRITE completed.
SQLDA or descriptor area not valid.
values in below in debug at time of error...
EVAL sqlInpda
SQLINPDA.SQLDAID = 'SQLDA '
SQLINPDA.SQLDABC = 16
SQLINPDA.SQLN = 0
SQLINPDA.SQLD = 16
EVAL sqlda
SQLDA.SQLDAID = ' '
SQLDA.SQLDABC = 1296
SQLDA.SQLN = 16
SQLDA.SQLD = 16
joblog error...
Message ID . . . . . . : SQL0804
Date sent . . . . . . : 10/11/17 Time sent . . . . . . : 09:23:35
Message . . . . : SQLDA or descriptor area not valid.
Cause . . . . . : If the error type is 2, 3, 9, 12, or 13, the entry in
error is 0, the value of SQLTYPE or TYPE is 0, and the value of SQLLEN,
SQLLONGLEN, or LENGTH is X'00000000'. If the error type is 13, the *N was
being set when the inconsistency was found. The specified SQLDA or
descriptor area is not valid because of error type 1. Error types and their
meanings are:
1 -- The value of SQLN is less than zero, the value of SQLD is not between
0 and 8000, the value of SQLD is greater than the value of SQLN, or that the
value of SQLD has not been initialized in REXX.
2 -- The value of SQLTYPE is either not valid or not supported or has not
been initialized in REXX.
More...
Press Enter to continue.
so clearly it is becausethe value of sqlInpDA.SQLD is greater than the value of sqlInpDA.SQLN
are my pointers set wrong? i'm no good with pointers... the templates help but still not a solid grasp.
I'm trying to redefine the descriptor area and execute a generic insert statement... i'm following Dan's tutorial at...
My code below reference his tutorial under "executing the statement"section...
* sql descriptor area
d t_sqlda ds template
d sqldaid 8
d sqldabc 10i 0
d sqln 5i 0
d sqld 5i 0
//---------------------------------
// SQL Descriptor Redefinition
//---------------------------------
d sqlda ds likeds(t_sqlda) based(sqlda#)
d sqlInpDA ds likeds(t_sqlda) based(sqlInpDA#)
...
g_sqlStmt = 'insert into ' +
%trim(g_libFile) +
' values (' +
%trim(g_valuesList) +
')';
sqlda# = %alloc(%size(sqlda));
sqlInpDA# = %alloc(%size(sqlInpDA));
sqlDA.SQLN = g_fieldArray.count;
//set SQLDABC equal to SQLN*LENGTH(SQLVAR) + 16.
sqlDA.SQLDABC = sqlDA.SQLN * 80 + 16;
//set SQLN and SQLD to the number of parameter markers.
sqlDA.SQLD = sqlDA.SQLN;
exec sql
prepare s1_write FROM :g_sqlStmt;
exec sql
describe input s1_write into :sqlInpDA;
exec sql
execute s1_write using descriptor :sqlInpDA; <-- SQLCODE -804
exec sql
execute immediate :g_sqlStmt;
My error is occurring at the -804 sqlcode noted above...
PREPARE of statement S1_WRITE completed.
DESCRIBE of prepared statement S1_WRITE completed.
SQLDA or descriptor area not valid.
values in below in debug at time of error...
EVAL sqlInpda
SQLINPDA.SQLDAID = 'SQLDA '
SQLINPDA.SQLDABC = 16
SQLINPDA.SQLN = 0
SQLINPDA.SQLD = 16
EVAL sqlda
SQLDA.SQLDAID = ' '
SQLDA.SQLDABC = 1296
SQLDA.SQLN = 16
SQLDA.SQLD = 16
joblog error...
Message ID . . . . . . : SQL0804
Date sent . . . . . . : 10/11/17 Time sent . . . . . . : 09:23:35
Message . . . . : SQLDA or descriptor area not valid.
Cause . . . . . : If the error type is 2, 3, 9, 12, or 13, the entry in
error is 0, the value of SQLTYPE or TYPE is 0, and the value of SQLLEN,
SQLLONGLEN, or LENGTH is X'00000000'. If the error type is 13, the *N was
being set when the inconsistency was found. The specified SQLDA or
descriptor area is not valid because of error type 1. Error types and their
meanings are:
1 -- The value of SQLN is less than zero, the value of SQLD is not between
0 and 8000, the value of SQLD is greater than the value of SQLN, or that the
value of SQLD has not been initialized in REXX.
2 -- The value of SQLTYPE is either not valid or not supported or has not
been initialized in REXX.
More...
Press Enter to continue.
so clearly it is becausethe value of sqlInpDA.SQLD is greater than the value of sqlInpDA.SQLN
are my pointers set wrong? i'm no good with pointers... the templates help but still not a solid grasp.
Comment