I m getting below error while running the code provided.
SQLCODE = -104
SQLSTATE = 42601
SQLERRMC = <END-OF-STATEMENT>:<IDENTIFIER>
ERRMSG = PREPARE STATEMENT FAILED
***
Can someone please let me know the issue. I think it is beacuse of DSNLOAD but i donot know how to find where it is presnt. I have so many libraries mapped to ISPLLIB.
/* db2 starts */
subsys = DBTG
qryvar1= "SELECT LENGTH,SCALE FROM SYSIBM.SYSCOLUMNS WHERE TBNAME = '"
qryvar2= tablnm
qryvar3= "' AND NAME ='"
qryvar4= var1
qryvar5= "' FETCH FIRST ROW ONLY WITH UR"
SQLSTMT= '"'||qryvar1 || qryvar2 || qryvar3 || qryvar4 || qryvar5||'"'
say sqlstmt
address tso "subcom dsnrexx"
if rc <> 0 then
do
x_rc = rxsubcom('add','dsnrexx','dsnrexx')
if x_rc <> 0 then
do
say 'problem loading '||subsys' environment'
exit 0
end
end
address dsnrexx "connect" subsys
if sqlcode <> 0 then
do
ERRMSG = 'CONNECTION FAILED'
call sqlca
end
address dsnrexx "execsql prepare s1 from :sqlstmt"
if sqlcode <> 0 then
do
ERRMSG = 'PREPARE STATEMENT FAILED'
call sqlca
end
address dsnrexx "execsql declare c1 cursor for s1"
if sqlcode <> 0 then
do
ERRMSG = 'DECLARE CURSOR FAILED'
call sqlca
end
address dsnrexx "execsql open c1"
if sqlcode <> 0 then
do
ERRMSG = 'OPEN CURSOR FAILED'
call sqlca
end
address dsnrexx "execsql fetch c1 into :length,:scale"
if sqlcode <> 0 then
do
ERRMSG = 'FETCH CURSOR FAILED'
call sqlca
end
address dsnrexx "execsql close c1"
if sqlcode <> 0 then
do
ERRMSG = 'CLOSE CURSOR FAILED'
call sqlca
end
SQLCA:
SAY "SQLCODE = " SQLCODE
SAY "SQLSTATE = " SQLSTATE
SAY "SQLERRMC = " SQLERRMC
SAY "ERRMSG = " ERRMSG
EXIT