Previous Topic Next topic Print topic


HOLD LOCATOR

The HOLD LOCATOR statement allows a LOB locator variable to retain its association with a value beyond a unit of work. The XDB operating environment does not support the LOB data type at this time.

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.

Authorization

None required.

Syntax

HOLD LOCATOR {host-variable}

Description:

host_variable,...

Identifies a host-variable locator variable that must have been previously declared according to the rules for declaring host variables. The locator variable type must be a binary large object locator, a character large object locator, or a double-byte character large object locator.

After the HOLD LOCATOR statement is executed, each locator variable in the host-variable list has the hold property. If a locator variable is not an established locator within the current unit of work, an invalid locator error occurs. When this error occurs and more than one host variable was specified in the HOLD LOCATOR statement, only the locators up to the first invalid locator are held. Locators listed after the first invalid locator are not held.

A host-variable LOB locator variable that has the hold property is freed (has its association between it and its value removed) when:

  • The SQL FREE LOCATOR statement is executed for the locator variable.
  • The SQL ROLLBACK statement 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.

EXEC SQL HOLD LOCATOR :LOCRES, :LOCHIST, :LOCPIC
Previous Topic Next topic Print topic