{"record":{"id":"04e4a04406804999","repo":"pentaho/pentaho-kettle","slug":"er-tostring","errorCode":null,"errorMessage":"er.toString()","messagePattern":"er\\.toString\\(\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":523,"sourceCode":"          ResultSet rs = db.openQuery( strSQL );\n          ResultSetMetaData resultSetMetaData = rs.getMetaData();\n          int columnCount = resultSetMetaData.getColumnCount();\n          if ( rs != null ) {\n            List<Object[]> list = new ArrayList<Object[]>();\n            while ( rs.next() ) {\n              Object[] objRow = new Object[columnCount];\n              for ( int i = 0; i < columnCount; i++ ) {\n                objRow[i] = rs.getObject( i + 1 );\n              }\n              list.add( objRow );\n            }\n            Object[][] resultArr = new Object[list.size()][];\n            list.toArray( resultArr );\n            db.close();\n            return resultArr;\n          }\n        } catch ( Exception er ) {\n          throw new RuntimeException( er.toString() );\n        }\n      } catch ( Exception e ) {\n        throw new RuntimeException( e.toString() );\n      }\n    } else {\n      throw new RuntimeException( \"The function call fireToDB requires 2 arguments.\" );\n    }\n    return oRC;\n  }\n\n  public static Object dateDiff( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n    if ( ArgList.length == 3 ) {\n      try {\n        if ( isNull( ArgList, new int[] { 0, 1, 2 } ) ) {\n          return new Double( Double.NaN );\n        } else if ( isUndefined( ArgList, new int[] { 0, 1, 2 } ) ) {\n          return undefinedValue;","sourceCodeStart":505,"sourceCodeEnd":541,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L505-L541","documentation":"Inside fireToDB, after the Database object is opened, the inner try block that executes the SQL and converts the result list into Object[][] wraps failures in a RuntimeException carrying er.toString() — the plain string of the original exception, losing the stack trace.","triggerScenarios":"The SQL execution inside the inner try fails: syntax error in the passed SQL, wrong table/column names, connection failure during execution, or result conversion problems.","commonSituations":"Invalid SQL statements passed from script; querying a table that does not exist on the target connection; database down or credentials changed between lookup and execution.","solutions":["Read the embedded message for the real database error and fix the SQL or connection accordingly.","Validate the SQL manually against the target database before running the transformation.","Wrap the fireToDB call in script try/catch to log details.","Replace fireToDB with a dedicated Execute SQL / Table Output step for complex work to get better error reporting."],"exampleFix":"// before\nfireToDB('MyConn', 'DELETE FROM logs WERE id < 100');\n// after\nfireToDB('MyConn', 'DELETE FROM logs WHERE id < 100');","handlingStrategy":"try-catch","validationCode":"// test SQL first: fireToDB('MyConn', 'SELECT 1');","typeGuard":null,"tryCatchPattern":"try { fireToDB('MyConn', sql); } catch (e) { var dbErr = String(e); /* inspect underlying SQL error text */ }","preventionTips":["Validate SQL syntax against the target DBMS before embedding it in scripts.","Quote identifiers and escape literals properly.","Prefer dedicated Execute SQL steps for complex statements to get full stack traces."],"tags":["database","sql","script-step"],"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"}