jdbc_updateΒΆ

jdbc_update constructs and executes an SQL UPDATE statement for each record in the input record stream. The field names specified in wherefields array and their respective values in the record will be used to construct WHERE clause.

jdbc_update(uri:uri_str, table:table_name_str, wherefields:fname_array)
jdbc_update(uri:uri_str, table:table_name_str, wherefields:fname_array,
            username:uname_str, password:pswd_str)
where:
  • uri_str - is Jdbc connection string. The format of string depends on the particular Jdbc driver of the database.
  • table_name_str - name of the table. The table must exist.
  • fname_array - names of fields used for constructing WHERE clause. Expressed as an array of strings.
  • uname_str - username of database user. Optional.
  • pswd_str - password of database user. Optional.

Note

Respective Jdbc drivers must be enabled in configuration.

On successful execution jdbc_update outputs following:

  • uri - Jdbc connection uri to the database
  • table - affected table
  • rows - number of rows affected by operation
  • field_count - input field count

Example: Update 10 records with generated data in an sqlite database table test using jdbc_update command:

1
2
3
4
5
6
dual(2,1)
| select(ip, description:'red fox jumps over brown dog')
| jdbc_update(uri:'jdbc:sqlite:file:/tmp/test.db'
              ,table:'test'         // update table 'test'
              ,wherefields:['ip']   // input stream field 'ip' values are used in where clause
);

Note

In order for this example to work: * SQLite JDBC driver must be enabled in SpectX configuration and * an SQLite database must exist in the path specified by JDBC connection string