{"record":{"id":"95e4e37623f8520a","repo":"pentaho/pentaho-kettle","slug":"the-function-call-firetodb-requires-2-arguments-95e4e3","errorCode":null,"errorMessage":"The function call fireToDB requires 2 arguments.","messagePattern":"The function call fireToDB requires 2 arguments\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":547,"sourceCode":"              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 Context.reportRuntimeError( er.toString() );\n        }\n      } catch ( Exception e ) {\n        throw Context.reportRuntimeError( e.toString() );\n      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call fireToDB requires 2 arguments.\" );\n    }\n    return oRC;\n  }\n\n  public static Object dateDiff( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function 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 Context.getUndefinedValue();\n        } else {\n          java.util.Date dIn1 = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );\n          java.util.Date dIn2 = (java.util.Date) Context.jsToJava( ArgList[1], java.util.Date.class );\n          String strType = Context.toString( ArgList[2] ).toLowerCase();\n          int iRC = 0;\n","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L529-L565","documentation":"fireToDB is a Kettle JavaScript (Rhino) extension function exposed to the 'Modified Java Script Value' step. It runs a SQL statement against a named database connection and requires exactly two arguments: the connection name and the SQL string. When ArgList.length != 2 the function throws this Rhino RuntimeError instead of executing.","triggerScenarios":"Calling fireToDB(connName, sql) with fewer or more than 2 arguments in the JavaScript step - e.g. omitting the SQL string, passing only the connection, or passing extra params directly instead of binding them in the SQL.","commonSituations":"Users copy JavaScript from DB connectors that use a different fireToDB signature; someone adds bind variables as extra arguments; a refactored script dropped the SQL argument.","solutions":["Pass exactly two arguments: fireToDB('ConnectionName', 'select count(*) from t')","If values must be parameterized, concatenate or use '?' placeholders supported by the Kettle fireToDB implementation rather than extra JS args","Check that the variable holding the SQL is defined and not undefined at call time"],"exampleFix":"// before\nvar cnt = fireToDB('MyDB');\n// after\nvar cnt = fireToDB('MyDB', 'SELECT COUNT(*) FROM mytable');","handlingStrategy":"validation","validationCode":"if (typeof connName !== 'string' || typeof sql !== 'string') throw new Error('fireToDB needs (connectionName, sql) strings');\nvar cnt = fireToDB(connName, sql);","typeGuard":null,"tryCatchPattern":"try { var r = fireToDB(conn, sql); } catch (e) { if (String(e).indexOf('requires 2 arguments') >= 0) { /* fix call site */ } else { throw e; } }","preventionTips":["Keep fireToDB calls wrapped in a small helper function that enforces the 2-argument signature","Never pass bind values as extra JS arguments","Validate the SQL variable is a non-empty string before calling"],"tags":["javascript","kettle","argument-count"],"backgroundTag":"missing-required-argument","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"}