{"record":{"id":"b1fbc7efe8f63d21","repo":"pentaho/pentaho-kettle","slug":"the-function-call-firetodb-requires-2-arguments","errorCode":null,"errorMessage":"The function call fireToDB requires 2 arguments.","messagePattern":"The function call fireToDB requires 2 arguments\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":529,"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 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;\n        } else {\n          java.util.Date dIn1 = (java.util.Date) ArgList[0];\n          java.util.Date dIn2 = (java.util.Date) ArgList[1];\n          String strType = ( (String) ArgList[2] ).toLowerCase();\n          int iRC = 0;\n","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L511-L547","documentation":"fireToDB(dbName, sql) accepts exactly two arguments — the connection name string and the SQL string. Any other argument count throws this RuntimeException, because the function indexes ArgList[0] and ArgList[1] unconditionally otherwise.","triggerScenarios":"Calling fireToDB with one argument or three or more, e.g. fireToDB('Conn') or fireToDB('Conn', sql, param).","commonSituations":"Trying to pass bind parameters as extra arguments (not supported); forgetting the SQL argument; confusion with other SQL helpers that take more parameters.","solutions":["Call with exactly two string arguments: fireToDB('ConnName', 'SQL STATEMENT').","Embed literal values into the SQL string instead of passing extra parameters (with care for SQL injection).","Use a Table Input/Execute SQL step with parameters for parameterized queries."],"exampleFix":"// before\nfireToDB('MyConn', sql, id);\n// after\nfireToDB('MyConn', 'DELETE FROM logs WHERE id = ' + id);","handlingStrategy":"validation","validationCode":"if (typeof connName === 'string' && typeof sql === 'string') { fireToDB(connName, sql); }","typeGuard":"function fireToDBSafe(c, s) { return (typeof c === 'string' && typeof s === 'string') ? fireToDB(c, s) : null; }","tryCatchPattern":"try { fireToDB(connName, sql); } catch (e) { if (/fireToDB requires 2 arguments/.test(String(e))) { /* fix arity */ } else { throw e; } }","preventionTips":["Pass exactly two string arguments.","Never rely on extra parameters being ignored.","Use parameterized SQL steps instead of extra function args for bindings."],"tags":["javascript","script-step","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"}