DB2 Version 10.1 for Linux, UNIX, and Windows

SYSTS_UPDATE procedure - Update the text search index

The SYSTS_UPDATE procedure updates the text search index to reflect the current contents of the text column with which the index is associated.

While the update is being performed, a search is possible. Until completion of the update, the search operates on a partially updated index.

The procedure issues an UPDATE INDEX text search administration command on the database server.

Authorization

The privileges held by the authorization ID of the statement must include the SYSTS_MGR role and at least one of the following authorities:
  • DATAACCESS authority
  • CONTROL privilege on the table on which the text index is defined
  • INDEX with SELECT privilege on the base table on which the text index is defined
In addition, for an initial update the authorization requirements apply as outlined in the CREATE TRIGGER statement.

Default PUBLIC privilege

None

Syntax

Read syntax diagramSkip visual syntax diagram
>>-SYSTS_UPDATE--(--index_schema--,--index_name--,-------------->

>--update_options--,--message_locale--,--message--)------------><

The schema is SYSPROC.

Procedure parameters

index_schema
An input argument of type VARCHAR(128) that specifies the schema of the text search index. The index_schema must follow the naming restriction for DB2® schema names. If the argument is null or an empty string, the value of CURRENT SCHEMA is used. The index_schema is case-sensitive.
index_name
An input argument of type VARCHAR(128) that specifies the name of the index. Together with index_schema, it uniquely identifies a text search index in a database. The index_name is case-sensitive.
update_options
An input argument of type VARCHAR(32K) that specifies update options. If no options are needed the argument can be null or an empty string. The possible values are:
UPDATE OPTIONS value Description
USING UPDATE MINIMUM This option enforces the use of the UPDATE MINIMUM value that is defined for the text search index and processes updates if the specified minimum number of changes have occurred.
FOR DATA REDISTRIBUTION This option specifies that a text search index in a partitioned database needs to be refreshed after data partitions were added or removed and a subsequent data redistribution operation completed. Search results may be inconsistent until the text search index was updated with the FOR DATA REDISTRIBUTION option.
ALLROWS This option specifies that an initial update should be attempted unconditionally.
UPDATEAUTOCOMMIT
  • This option specifies the number of index updates after which a commit is executed to preserve the previous work automatically for either initial or incremental updates.
    • For initial updates, the index update will process batches of documents from a base table after the trigger to capture data updates is activated. After the number of documents updated reaches the COMMITCOUNT number, the server does an interim commit. Log entries generated by unprocessed documents are removed from the staging table. Using the UPDATEAUTOCOMMIT option for an initial text index update leads to a significant increase of execution time.
    • For incremental updates, log entries which have been processed are removed correspondingly from staging table with each interim commit. COMMITCOUNT counts the number of documents updated, not the number of staging table entries.
  • Starting in DB2 Version 10.1 Fix Pack 3 and later fix packs, specifies the number of rows or number of hours after which a commit is run to automatically preserve the previous work for either initial or incremental updates.

    If you specify the number of rows:
    • After the number of documents that are updated reaches the COMMITCOUNT number, the server applies a commit. COMMITCOUNT counts the number of documents that are updated by using the primary key, not the number of staging table entries.
    If you specify the number of hours:
    • The text index is committed after the specified number of hours is reached. The maximum number of hours is 24.

    For initial updates, the index update processes batches of documents from the base table. After the commitsize value is reached, update processing completes a COMMIT operation and the last processed key is saved in the staging table with operational identifier '4'. This key is used to restart update processing either after a failure or after the number of specified commitcycles are completed. If a commitcycles is specified, the update mode is modified to incremental to initiate capturing changes by using the LOGTYPE BASIC option to create triggers on the text table. However, until the initial update is complete, log entries that are generated by documents that have not been processed in a previous cycle are removed from the staging table.

    Using the UPDATEAUTOCOMMIT option for an initial text index update leads to a significant increase of execution time.

    For incremental updates, log entries that are processed are removed correspondingly from the staging table with each interim commit.

COMMITTYPEcommittype

Starting in DB2 Version 10.1 Fix Pack 3 and later fix packs, specifies rows or hours for the UPDATEAUTOCOMMIT index configuration option. The default is rows.

COMMITCYCLEScommitcycles

Starting in DB2 Version 10.1 Fix Pack 3 and later fix packs, specifies the number of commit cycles. The default is 0 for unlimited cycles.

If cycles are not explicitly specified, the update operation uses as many cycles as required based on the batch size that is specified with the UPDATEAUTOCOMMIT option to finish the update processing.

You can use this option with the UPDATEAUTOCOMMIT setting with a committype.

message_locale
An input argument of type VARCHAR(33) that specifies the locale to be used for any error message returned. If the argument is null or an empty string, or the message files for the specified locale are not available on the server, 'en_US' is used.
message
An output argument of type VARCHAR(32K) that specifies a warning or informational message for a successfully completed operation.

Examples

Example 1: In the following example, the text search index that was created with index_schema 'db2ts' and index_name 'myTextIndex' is being updated. A NULL value in the place of the update_options means that an update is unconditionally started when the stored procedure is called. Any error messages are requested to be returned in English. When the procedure succeeds, the output parameter message indicative of the successful operation is returned to the caller.
  CALL SYSPROC.SYSTS_UPDATE
  ('db2ts', 'myTextIndex', '', 'en_US', ?)
An example of output from this query:
  Value of output parameters
  --------------------------
  Parameter Name  : MESSAGE
  Parameter Value : Operation completed successfully.
Example 2: Update a text index after an operation was executed on the partition group associated with the base table, and return any error messages in English.
  CALL SYSPROC.SYSTS_UPDATE
  ('db2ts', 'myTextIndex2', 'FOR DATA REDISTRIBUTION', 'en_US', ?) 
  Value of output parameters
  --------------------------
  Parameter Name  : MESSAGE
  Parameter Value : Operation completed successfully.

  Return Status = 0

Example 3: In the following example, SYSTS_UPDATE is called to update a text search index with index_schema 'db2ts' and index_name 'myTextIndex3'. This index does not exist and results in an error.

  CALL SYSPROC.SYSTS_UPDATE('db2ts', 'myTextIndex3', 'USING UPDATE MINIMUM', 
		'en_US', ?)
  SQL20427N An error occurred during a text search administration 
  procedure or command. The error message is "CIE00316 Text search 
  index "db2ts"."myTextIndex3" does not exist. ". SQLSTATE 38H14

Usage notes