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

SQLCODE -517 - Cursor Cannot Be Associated With Prepared Statement

What does SQLCODE -517 - Cursor Cannot Be Associated With Prepared Statement mean in RPG (IBM i / AS/400)?

A DECLARE CURSOR referenced a statement name whose prepared statement is not a SELECT, so SQL cannot associate a cursor with it.

SQLCODE -517 - Cursor Cannot Be Associated With Prepared StatementDB2 for i · SQLRPGLE

Condition

A DECLARE CURSOR referenced a statement name whose prepared statement is not a SELECT, so SQL cannot associate a cursor with it.

Fix

Confirm the dynamic SQL text being PREPAREd is actually a SELECT before declaring a cursor for it, and route non-SELECT dynamic statements through EXECUTE IMMEDIATE or EXECUTE instead.

Related db2 sqlcode