mardi 23 février 2016

Writing string into table within procedure in DB2

I have the following snipplet:

SET retcode = SQLCODE;

IF(retcode='0')THEN
    SET SQLCMDINS = 'INSERT INTO RESULTTBL(SQLC, RET) VALUES ( '' '||SQLCMD||' '' , '||retcode||' )';
    PREPARE myStmt2 FROM SQLCMDINS; 
    EXECUTE myStmt2;
ELSE
    SET SQLCMDINS = 'INSERT INTO RESULTTBL(SQLC, RET) VALUES ("'|| SQLCMD ||'", '|| retcode ||')';
    PREPARE myStmt2 FROM SQLCMDINS; 
    EXECUTE myStmt2;
END IF;   

The problem is that SQLCMD is not written into the table. The retcode is working fine, but I get nothing for the string. The SQLCMD is the sql command that is being processed during that loop.

Any ideas on how to make this work?

Thanks in advance.

TheVagabond

Aucun commentaire:

Enregistrer un commentaire