{"record":{"id":"c939f58be9c83052","repo":"pentaho/pentaho-kettle","slug":"unable-to-call-procedure","errorCode":null,"errorMessage":"Unable to call procedure","messagePattern":"Unable to call procedure","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/Database.java","lineNumber":4939,"sourceCode":"\n          } else {\n            // Save the update count if it is available (> -1)\n            updateCount = cstmt.getUpdateCount();\n          }\n\n          moreResults = cstmt.getMoreResults();\n\n        } finally {\n          if ( rs != null ) {\n            rs.close();\n            rs = null;\n          }\n        }\n      } while ( moreResults || ( updateCount > -1 ) );\n\n      return ret;\n    } catch ( Exception ex ) {\n      throw new KettleDatabaseException( \"Unable to call procedure\", ex );\n    }\n  }\n\n  public void closeProcedureStatement() throws KettleDatabaseException {\n    // CHE: close the callable statement involved in the stored\n    // procedure call!\n    try {\n      if ( cstmt != null ) {\n        cstmt.close();\n        cstmt = null;\n      }\n    } catch ( SQLException ex ) {\n      throw new KettleDatabaseException( BaseMessages.getString(\n        PKG, \"Database.Exception.ErrorClosingCallableStatement\" ), ex );\n    }\n  }\n\n  /**","sourceCodeStart":4921,"sourceCodeEnd":4957,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Database.java#L4921-L4957","documentation":"Thrown when executing a stored procedure via a CallableStatement fails at any stage — preparing, binding parameters, executing, or reading results/out-parameters. Kettle wraps the exception as \"Unable to call procedure\" in a KettleDatabaseException.","triggerScenarios":"Database.callProcedure(...) with wrong parameter count/types vs the procedure signature, invalid procedure name or missing EXECUTE grant, wrong in/out parameter declaration, or the procedure raising an internal SQL error.","commonSituations":"Calling a procedure with parameters in wrong order; missing EXECUTE privilege on the procedure; procedure name not qualified with schema/package; procedure itself throws ORA-/SQL exceptions; using a driver that mishandles CallableStatement out-params.","solutions":["Match the call string exactly to the procedure signature: correct schema/package name, parameter order, count, and types; declare out-params with proper JDBC types.","Grant EXECUTE privilege on the procedure to the DB user.","Run the procedure call manually (SQL client) to see the database's native error, then fix that underlying SQL issue.","Read the chained exception (getCause) for the exact SQLException from the driver."],"exampleFix":"// before\ndb.callProcedure(callable, \"MYPROC\", \"?\", \"?\", \"?\", 3, \"IIO\"); // wrong order/types\n\n// after\n// signature: myproc(p_id IN NUMBER, p_name OUT VARCHAR2) RETURN NUMBER\ndb.callProcedure(callable, \"SCHEMA.MYPROC\", \"? = call ?(?, ?)\", \"000\", \"NIO\", 3, \"NIO\");","handlingStrategy":"try-catch","validationCode":"// verify before calling:\n// 1) user has EXECUTE on the procedure\n// 2) parameter count/order/types match the signature\n// 3) out-param JDBC types are declared correctly\nDatabaseMetaData md = db.getDatabaseMetaData();\ntry (ResultSet rs = md.getProcedures(null, schema, procName)) {\n  if (!rs.next()) throw new IllegalStateException(\"Procedure not found: \" + procName);\n}","typeGuard":null,"tryCatchPattern":"try {\n  ret = db.callProcedure(...);\n} catch (KettleDatabaseException e) {\n  throw new RuntimeException(\"Procedure call failed: \" + e.getCause(), e);\n}","preventionTips":["Test the exact procedure call in a SQL client first","Qualify procedure names with schema/package","Match the in/out parameter mask exactly to the signature","Grant EXECUTE on the procedure to the connecting user"],"tags":["jdbc","stored-procedure","callablestatement","database"],"backgroundTag":"sql-query-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}