HOLD LOCATOR

Start of changeThe HOLD LOCATOR statement allows a LOB or XML locator variable to retain its association with a value beyond a unit of work.End of change

Invocation

This statement can only be embedded in an application program. It cannot be issued interactively. It is an executable statement that can be dynamically prepared. However, the EXECUTE statement with the USING clause must be used to execute the prepared statement. HOLD LOCATOR cannot be used with the EXECUTE IMMEDIATE statement. It must not be specified in REXX.

Authorization

None required.

Syntax

Read syntax diagramSkip visual syntax diagram
                 .-,--------.   
                 V          |   
>>-HOLD LOCATOR----variable-+----------------------------------><

Description

variable,...
Identifies a variable that must be declared in accordance with the rules for declaring variable locator variables. An indicator variable must not be specified. The locator variable type must be a binary large object locator, a character large object locator, a double-byte character large object locator, Start of changeor an XML locator.End of change

After the HOLD LOCATOR statement is executed, each locator variable in the variable list has the hold property.

The variable must currently have a locator assigned to it. That is, a locator must have been assigned during this unit of work (by a CALL, FETCH, SELECT INTO, SET variable, or VALUES INTO statement) and must not subsequently have been freed (by a FREE LOCATOR statement); otherwise, an error is raised.

If more than one variable is specified in the HOLD LOCATOR statement and an error occurs on one of the locators, no locators will be held.

Note

Start of changeA LOB or XML locator variable that has the hold property is freed (has its association between it and its value removed) when:End of change

  • The SQL FREE LOCATOR statement is executed for the locator variable.
  • The SQL ROLLBACK statement without a HOLD option is executed.
  • The SQL session is terminated.

Example

Assume that the employee table contains columns RESUME, HISTORY, and PICTURE and that locators have been established in a program to represent the values represented by the columns. Give the CLOB locator variables LOCRES and LOCHIST, and the BLOB locator variable LOCPIC the hold property.

   HOLD LOCATOR :LOCRES,:LOCHIST,:LOCPIC