So I was testing a program, and one of the "insert into table values()" embedded SQL statements was failing but not reporting an error. When I stepped through it in debug, the Exec SQL statement did not execute, program flow skipped form the previous statement to the next. I checked the compile listing, and the Exec SQL had been commented out as normal, but had not been replaced with the assignments and procedure call you normally get for an embedded SQL statement. It is like the compiler had silently decided to skip that statement.
After much experimenting I found the cause was the name of one of the host variables that was among the insert values. Simplified code:
It was "myds.include". The RDi syntax highlighter was highlighting the "include" text part of the name in blue, but I didn't give it any thought at the time. When I renamed the host variable to "includeItem" then it worked.
It seems that a host variable named include will cause the SQL statement to not be compiled.
I do not know if it happens when include is the whole host variable name, or just if it is the subfield name in a qualified DS. I also do not know if it happens different types of SQL statement.
Has anyone else seen this?
This page lists the host variable name restrictions, and makes no mention of include: https://www.ibm.com/support/knowledg...ajprpiamco.htm
And even if include was a restricted value, I would expect the compiler to tell me that and disallow compilation, or at least provide a warning. But it was entirely silent.
After much experimenting I found the cause was the name of one of the host variables that was among the insert values. Simplified code:
Code:
dcl-ds myds qualified; var1 char(5); var2 char(5); include char(1); end-ds; exec sql insert into mytable (field1, field2, field3) values(:myds.var1, :myds.var2, :myds.include);
It seems that a host variable named include will cause the SQL statement to not be compiled.
I do not know if it happens when include is the whole host variable name, or just if it is the subfield name in a qualified DS. I also do not know if it happens different types of SQL statement.
Has anyone else seen this?
This page lists the host variable name restrictions, and makes no mention of include: https://www.ibm.com/support/knowledg...ajprpiamco.htm
And even if include was a restricted value, I would expect the compiler to tell me that and disallow compilation, or at least provide a warning. But it was entirely silent.
Comment