Database Plugin - Macros - Update DbUnit


# UPDATE_DBUNIT {dataset} INTO {database}

What ?

This macro will update all the data listed in the ‘dataset file’ into the ‘database’. This update operation assumes that table data already exists in the target database and fails if this is not the case.

Underlying instructions :

LOAD {dataset} AS __temp{%%rand1}.file

CONVERT __temp{%%rand1}.file TO file(param.relativedate) AS __temp_{%%rand2}.file
CONVERT __temp_{%%rand2}.file TO xml(structured) AS __temp_{%%rand3}.xml
CONVERT __temp_{%%rand3}.xml TO dataset.dbunit(dataset) AS __temp_{%%rand4}.dbu

EXECUTE insert WITH __temp_{%%rand4}.dbu ON {database} USING $(operation:update) AS __temp_{%%rand5}.result

> Input :

  • {database} : The name (in the context) of the database to use (database type target).
  • {dataset} : A flat xml dbunit dataset file.

Remark : The file designed by {dataset} must respect the same rules than a file which would serve to create an SKF dataset.dbunit type resource via the converter (From xml to dataset.dbunit).

Example :

# UPDATE_DBUNIT path/to/dataset.xml INTO my_database

Database overview :

../../_images/update-dbunit-database-overview.png

In the dataset, we update employees’ information :

../../_images/update-dbunit-dataset.png

SKF script :

../../_images/update-dbunit-macro.png

All employees are updated :

../../_images/update-dbunit-database-result.png


# UPDATE_DBUNIT {dataset} INTO {database} WITH CONFIG {config}

What ?

This macro will update all the data listed in the ‘dataset file’ into the ‘database’ using a DbUnit configuration file. This update operation assumes that table data already exists in the target database and fails if this is not the case.

Underlying instructions :

LOAD {config} AS __temp{config}{%%rand1}.file
CONVERT __temp{config}{%%rand1}.file TO conf.dbunit AS __temp{config}{%%rand2}.conf

LOAD {dataset} AS __temp{%%rand3}.file

CONVERT __temp{%%rand3}.file TO file(param.relativedate) AS __temp_{%%rand4}.file
CONVERT __temp_{%%rand4}.file TO xml(structured) AS __temp_{%%rand5}.xml
CONVERT __temp_{%%rand5}.xml TO dataset.dbunit(dataset) AS __temp_{%%rand6}.dbu

EXECUTE insert WITH __temp_{%%rand6}.dbu ON {database} USING $(operation:update),__temp{config}{%%rand2}.conf AS __temp_{%%rand7}.result

> Input :

  • {dataset} : A flat xml dbunit dataset file.
  • {database} : The name (in the context) of the database to use (database type target).
  • {config} : A configuration file for DbUnit (‘.properties’).

Remarks :

  1. The file designed by {dataset} must respect the same rules than a file which would serve to create an SKF dataset.dbunit via the converter (From xml to dataset.dbunit).
  2. The file designed by {config} must respect the same rules than a file which would serve to create an SKF conf.dbunit type resource via the converter (From file to conf.dbunit).

Example :

# UPDATE_DBUNIT path/to/dataset.xml INTO my_database WITH CONFIG path/to/my_config_dbunit.properties


# UPDATE_DBUNIT {dataset} INTO {database} USING {ppkfilter}

What ?

This macro will update all datas listed in the ‘dataset file’ into the ‘database’ using a DbUnit filter. This update operation assumes that table data already exists in the target database and fails if this is not the case.

Underlying instructions :

LOAD {dataset} AS __temp{%%rand1}.file
CONVERT __temp{%%rand1}.file TO file(param.relativedate) AS __temp{%%rand2}.file
CONVERT __temp{%%rand2}.file TO xml(structured) AS __temp{%%rand3}.xml
CONVERT __temp{%%rand3}.xml TO dataset.dbunit(dataset) AS __temp{%%rand4}.dbu

LOAD {ppkfilter} AS __temp{%%rand5}.file
CONVERT __temp{%%rand5}.file TO properties(structured) AS __temp{%%rand6}.props
CONVERT __temp{%%rand6}.props TO conf.dbunit.ppk(from.properties) AS __temp{%%rand7}.ppk

EXECUTE insert WITH __temp{%%rand4}.dbu ON {database} USING __temp{%%rand7}.ppk,$(operation:update) AS __temp_{%%rand8}.result

> Input :

  • {dataset} : A flat xml dbunit dataset file.
  • {database} : The name (in the context) of the database to use (database type target).
  • {ppkfilter} : A DbUnit filter referring to pseudo primary keys (‘.properties’).

Example :

# UPDATE_DBUNIT path/to/dataset.xml INTO my_database USING path/to/my_filter_dbunit.properties


# UPDATE_DBUNIT {dataset} INTO {database} WITH CONFIG {config} USING {ppkfilter}

What ?

This macro will update all the data listed in the ‘dataset file’ into the ‘database’ using a DbUnit configuration file and a DbUnit filter. This update operation assumes that table data already exists in the target database and fails if this is not the case.

Underlying instructions :

LOAD {config} AS __temp{config}{%%rand1}.file
CONVERT __temp{config}{%%rand1}.file TO conf.dbunit AS __temp{config}{%%rand2}.conf

LOAD {dataset} AS __temp{%%rand3}.file
CONVERT __temp{%%rand3}.file TO file(param.relativedate) AS __temp_{%%rand4}.file
CONVERT __temp_{%%rand4}.file TO xml(structured) AS __temp_{%%rand5}.xml
CONVERT __temp_{%%rand5}.xml TO dataset.dbunit(dataset) AS __temp_{%%rand6}.dbu

LOAD {ppkfilter} AS __temp{%%rand7}.file
CONVERT __temp{%%rand7}.file TO properties(structured) AS __temp{%%rand8}.props
CONVERT __temp{%%rand8}.props TO conf.dbunit.ppk(from.properties) AS __temp{%%rand9}.ppk

EXECUTE insert WITH __temp_{%%rand6}.dbu ON {database} USING __temp{%%rand9}.ppk,$(operation:update),__temp{config}{%%rand2}.conf AS __temp_{%%rand10}.result

> Input :

  • {dataset} : A flat xml dbunit dataset file.
  • {database} : The name (in the context) of the database to use (database type target).
  • {config} : A configuration file for DbUnit (‘.properties’).
  • {ppkfilter} : A DbUnit filter referring to pseudo primary keys (‘.properties’).

Example :

# UPDATE_DBUNIT path/to/dataset.xml INTO my_database WITH CONFIG path/to/my_config_dbunit.properties USING path/to/my_filter_dbunit.properties