Nonstop Database, HiRDB Version 9 Description

[Contents][Glossary][Index][Back][Next]

6.8.13 Partial update or retrieval of BLOB or BINARY data

Organization of this subsection
(1) Explanation of partial update or retrieval of BLOB or BINARY data
(2) Examples of partial update or retrieval of BLOB or BINARY data

(1) Explanation of partial update or retrieval of BLOB or BINARY data

When BLOB or BINARY data is updated after new data has been added to a registered BLOB or BINARY data item, or when an entire BLOB or BINARY data item is retrieved as the result of BLOB or BINARY data being searched, both the server and the client must allocate a large amount of memory for the BLOB or BINARY data, putting a strain on memory resources.

When you partially update or retrieve BLOB or BINARY data, you can avoid straining memory resources, because you need to allocate only the memory required for the actual amount of BLOB or BINARY data being added or extracted.

However, for BINARY data, the definition length must be 32,001 bytes or greater.

BLOB or BINARY data addition update:
By specifying a concatenation operation in the SET clause of the UPDATE statement, you can add new data to BLOB or BINARY data that has been registered.

BLOB and BINARY data partial extraction:
By specifying the SUBSTR scalar function, you can extract only a specified portion of the BLOB or BINARY data.

BLOB or BINARY data back-end deletion update:
By specifying the SUBSTR scalar function in which the constant 1 is specified for the processing target column and start position in the SET clause of the UPDATE statement, you can delete only the back-end portion of the BLOB or BINARY data.

For details about partial update or retrieval of BLOB or BINARY data, see the HiRDB Version 9 UAP Development Guide.

(2) Examples of partial update or retrieval of BLOB or BINARY data

(a) BLOB data addition update

A single BLOB data item is stored across a number of files. The following figure shows an example of BLOB data addition updating.

Figure 6-18 Example of BLOB data addition updating

[Figure]

Explanation
  1. BLOB data from file 1 is inserted into column C2 of row A in table T1.
  2. Addition updating is performed by concatenating BLOB data of file 2 to column 2 of row A. Subsequent data additions are also performed in a similar manner.
(b) BLOB data partial extraction

An area in file 2 is extracted from the BLOB data in column C2 of row A that was stored using BLOB data addition updating. The following figure shows an example of BLOB data partial extraction.

Figure 6-19 Example of BLOB data partial extraction

[Figure]

Explanation
Using the SUBSTR scalar function, from column 2 of row A, the length of the data from the data column of file 2 (200 [Figure] 1,024 = 204,800 bytes) is extracted beginning at the start position of the data column of file 2 (at the 100 [Figure] 1,024 + 1th = 102,401st byte position).
(c) BLOB data back-end deletion update

The back-end portion is deleted from the BLOB data in column C2 of row A that was stored using BLOB data addition updating, leaving only files 1 and 2. The following figure shows an example of BLOB data back-end deletion update.

Figure 6-20 Example of BLOB data back-end deletion update

[Figure]

Explanation
Using the SUBSTR scalar function, only the length of data from the first byte beginning at the start position of the data column of file 1 through files 1 and 2 (100 [Figure] 1,024 + 200 [Figure] 1,024 = 307,200 bytes) is replaced with the extracted data and updated. This leaves only files 1 and 2 and deletes the data at the back end.