RPG (IBM i / AS/400) · DB2 SQLCODE

SQLCODE -311 - Invalid Length Control Field

What does SQLCODE -311 - Invalid Length Control Field mean in RPG (IBM i / AS/400)?

A varying-length host variable's length subfield held a negative value or a value larger than the variable's declared maximum, so SQL couldn't determine how much data to move.

SQLCODE -311 - Invalid Length Control FieldDB2 for i · SQLRPGLE

Condition

A varying-length host variable's length subfield held a negative value or a value larger than the variable's declared maximum, so SQL couldn't determine how much data to move.

Fix

RPG's VARYING keyword normally manages this length field for you, so check for manually built SQLDAs or API calls that set it incorrectly, and never leave that subfield uninitialized before an INSERT or UPDATE.

Related db2 sqlcode