This topic describes how to update IBM Director database tables by sending user-formatted commands.
IBM Director database tables are updated by requests sent as commands through the IBM Director IPC. You can perform the following tasks using the IBM Director database update interface:
See Database update return codes for information on return codes for database operations.
To perform each of these operations using Java, create a database Command object specific to the operation. To perform each of these operations using C or C++, create several byte arrays that contain the command parameters. The Command objects or byte arrays are passed as parameters to an IPC command along with the appropriate command code.
Refer to IBM Director Interprocess Communication for information on coding Command objects and IPC commands.
Before updating a table you must use the findTableByClassName command to request the token name (an alias) for the table you want to update. You only have to use this command once.
Sample code that implements the findTableByClassName command is in the SampleInventoryCollectorExtension.java file.
Use the store rows command to perform table insert and update row operations. The store rows command can contain row data for one or more rows in one or more tables.
For tables that have keys, store rows handles both inserts and updates. The database inserts the row if a row with that key does not already exist, otherwise it updates the existing row with the new data.
For tables that do not have keys, store rows inserts all rows. You cannot update rows in non-key tables.
For keyed tables, each updated or inserted row must contain values for all key columns.
Values do not have to be specified for columns that are not part of a key. If a value is not specified for a non-key column, the database engine treats the column differently for inserted and updated rows:
You can issue two types of store rows commands:
If you are using Java, the store rows command object is TWGDbStoreRowsCmd. Each row is a TWGDbStoreRow object that is added to the command.
If you are using C++, the store rows parameters are passed directly as input parameters to the Command object.
Use the delete rows command to delete database table rows. The command uses a column filter that describes the table, column, value(s), and operator to determine whether a row in the table should be deleted.
If you are using Java, the database command object is TWGDbDeleteRowsCmd.
The column filter parameter is a TWGDbColumnFilter subclass object.
If you are using C++, the delete rows parameters are passed directly as input parameters to the Cmd object.
Use the replace managed object command to replace database table rows for a single managed object. The command contains the managed object ID to be deleted and the replacement rows for the object.
The IBM Director database engine uses replacement rows to determine from which tables the managed object should be deleted. If a table contains data for a managed object for which no replacement rows have been specified, that data is not deleted. Use the delete rows command for that table to delete those rows.
Deletes and row updates in the replace managed object command are performed as a single transaction. If any delete or insert fails, the changes are not committed to the database.
The replacement rows are the same as those used in the store rows command, and the insert/update process is handled identically.
If you are using Java, the database command object is TWGDbReplaceManagedObjCmd.
Sample code that replaces database table rows is provided in the SampleCreateRunQueryt.java file.
If you are using C++, the replace managed object parameters are passed directly as input parameters to the Cmd object.