I have an SQLRPGLE program which accepts the SQL statement as an input parameter to the program from an RPGLE program. (The SQL is entered by user .) My intention is to validate the SQL and make a prepare statement out of it, and then initiates a Fetch Next from C1 into a :wSTR. Check for the SQLCOD to determine whether the SQL is valid. IF valid i will display the result to user by moving the wSTR value to a display file field(of length 350A). If I enter a correct SQL I will get the result, if for the second time I enter some irrelevant values, I am still getting the previous output. I am closing the cursor at the end and also at the beginning of the program. I am clearing the field wSTR also. In debug before the prepare statement I can see wSTR as blanks. But after the fetch, though the SQL is bad, it returns the previous output ans SQLCOD as Zeros. This looks very strange. Please help me to figure out the issue.
Free Guide: Managing storage for virtual environments
Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!