← All errors

SQLCODE -518

SQL0518 Prepared statement not found

IBM message text
Prepared statement &1 not found.
SQLCODE
-518
SQLSTATE
07003

Most common cause

EXECUTE of a statement that was not prepared, often because the PREPARE failed and the error was not checked.

Other causes

  • EXECUTE of a prepared SELECT, which must be handled with a cursor instead.
  • The statement was prepared in another call, and the CLOSQLCSR option discarded it.
  • A COMMIT or ROLLBACK deleted the prepared statement.

How to fix it

Check SQLCODE after PREPARE. For dynamic SELECTs use DECLARE CURSOR FOR statement_name.

Related errors

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