当我们尝试从未打开的CURSOR中获取数据时,查询将失败。在这种情况下,SQLCA的SQLCODE字段将填充DB2错误代码-501。根据IBM文档,-501错误代码指出:
“THE CURSOR IDENTIFIED IN A FETCH OR CLOSE STATEMENT IS NOT OPEN”
当我们尝试打开已经打开的游标时,查询将失败,并且在SQLCA的SQLCODE字段中将获得错误代码-502。根据IBM文档-502错误代码指出:
“THE CURSOR IDENTIFIED IN AN OPEN STATEMENT IS ALREADY OPEN”