← All errors

SQLCODE -313

SQL0313 Number of host variables not valid

IBM message text
Number of host variables not valid.
SQLCODE
-313
SQLSTATE
07001, 07004

Most common cause

In EXECUTE ... USING or OPEN ... USING the number of variables does not match the parameter markers (?) of the prepared statement.

Other causes

  • A dynamic statement whose number of markers changes with conditions, with a fixed USING.

How to fix it

Count the ? in the prepared statement and pass the same number of variables, in the same order.

Related errors

Text and codes from IBM documentation for 7.6. Checked on .