pentaho/pentaho-kettle · error

The function call fireToDB requires 2 arguments.

Error message

The function call fireToDB requires 2 arguments.

What it means

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.

Solutions

  1. Pass exactly two arguments: fireToDB('ConnectionName', 'select count(*) from t')
  2. If values must be parameterized, concatenate or use '?' placeholders supported by the Kettle fireToDB implementation rather than extra JS args
  3. Check that the variable holding the SQL is defined and not undefined at call time

Example fix

// before
var cnt = fireToDB('MyDB');
// after
var cnt = fireToDB('MyDB', 'SELECT COUNT(*) FROM mytable');
Defensive patterns

Strategy: validation

Validate before calling

if (typeof connName !== 'string' || typeof sql !== 'string') throw new Error('fireToDB needs (connectionName, sql) strings');
var cnt = fireToDB(connName, sql);

Try / catch

try { var r = fireToDB(conn, sql); } catch (e) { if (String(e).indexOf('requires 2 arguments') >= 0) { /* fix call site */ } else { throw e; } }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/95e4e37623f8520a. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:547

              Object[] objRow = new Object[columnCount];
              for ( int i = 0; i < columnCount; i++ ) {
                objRow[i] = rs.getObject( i + 1 );
              }
              list.add( objRow );
            }
            Object[][] resultArr = new Object[list.size()][];
            list.toArray( resultArr );
            db.close();
            return resultArr;
          }
        } catch ( Exception er ) {
          throw Context.reportRuntimeError( er.toString() );
        }
      } catch ( Exception e ) {
        throw Context.reportRuntimeError( e.toString() );
      }
    } else {
      throw Context.reportRuntimeError( "The function call fireToDB requires 2 arguments." );
    }
    return oRC;
  }

  public static Object dateDiff( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 3 ) {
      try {
        if ( isNull( ArgList, new int[] { 0, 1, 2 } ) ) {
          return new Double( Double.NaN );
        } else if ( isUndefined( ArgList, new int[] { 0, 1, 2 } ) ) {
          return Context.getUndefinedValue();
        } else {
          java.util.Date dIn1 = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );
          java.util.Date dIn2 = (java.util.Date) Context.jsToJava( ArgList[1], java.util.Date.class );
          String strType = Context.toString( ArgList[2] ).toLowerCase();
          int iRC = 0;

View on GitHub (pinned to f3058517a1)