SQLCODE -312
SQL0312 Variable not defined or not usable
- IBM message text
- Variable &1 not defined or not usable for reason code &2.
- SQLCODE
- -312
- SQLSTATE
- 42618
Most common cause
The precompiler cannot find or use the variable: wrong name, a variable of another procedure, or a type with no SQL equivalent. The message gives a reason code.
Other causes
- A host variable written in a dynamic statement: there you need parameter markers (?) (reason 8).
- A subfield of a qualified data structure used without the structure's name.
How to fix it
Check the variable's name, scope and the reason code. For qualified data structures use :ds.field; in dynamic SQL replace variables with ?.
Text and codes from IBM documentation for 7.6. Checked on .