Oracle8i Application Developer's Guide - Large Objects (LOBs) Release 2 (8.1.6) Part Number A76940-01 |
|
Temporary LOBs, 3 of 29
Oracle8i supports the definition, creation, deletion, access, and update of temporary LOB
s in the following programmatic environments or 'interfaces':
DBMS_LOB
package
PRO*C
precompiler
OCI
The 'interfaces' listed above, operate on temporary LOB
s through locators in the same way that they do for permanent LOB
s. Since temporary LOBs are never part of any table, you cannot use SQL DML to operate on them. You must manipulate them using the DBMS_LOB
package, OCI, or the other programmatic interfaces.
SQL support for temporary LOB
s is available in that temporary LOB
locators can be used as IN
values, with values accessed through a locator. Specifically, they can be used as follows:
INSERT
, UPDATE
, DELETE
, or SELECT. For example
:
SELECTpattern
FROMcomposite_image WHERE temp_lob_pattern_id =
somepattern_match_function(lobvalue)
;
SELECTPermanentLob
INTOTemporaryLob_loc FROM Demo_tab WHERE Column1 := 1
;
Compare the use case model diagrams for temporary LOBs with the Figure 10-1, "Use Case Model Diagram: Internal Temporary LOBs (part 1 of 2)", and Figure 10-2, "Use Case Model Diagram: Internal temporary LOBs (part 2 of 2)". Observe that you can use the following functions for internal persistent LOBs and temporary LOBs:
DBMS_LOB
package PL/SQL procedures (COMPARE
, INSTR
, SUBSTR
)
DBMS_LOB
package PL/SQL procedures and corresponding OCI
functions (Append
, Copy
, Erase
, Getlength
, Loadfromfile
, Read
, Trim
, Write, WriteAppend
).
OCI
functions (OCILobAssign
, OCILobLocatorIsInit
, etc.
).
In addition, you can use the ISTEMPORARY
function to determine if a LOB is temporarily based on its locator.
Temporary LOBs are not stored permanently in the database like other data. The data is stored in temporary tablespaces and is not stored in any tables. This means you can CREATE
an internal temporary LOB
(BLOB
,CLOB
, NCLOB
) on the server independent of any table, but you cannot store that LOB.
Since temporary LOB
s are not associated with table schema, there is no meaning to the terms "inline" and "out-of-line" for temporary LOB
s.
The default lifetime of a temporary LOB
is a session.
The interface for creating temporary LOB
s includes a parameter that lets you specify the default scope of the life of the temporary LOB
. By default, all temporary LOB
s are deleted at the end of the session in which they were created. If a process dies unexpectedly or the database crashes, all temporary LOB
s are deleted.
OCI
users can group temporary LOB
s together into a logical bucket.
"OCIDuration"
represents a store for temporary LOB
s. There is a default duration for every session into which temporary LOB
s are placed if you do not specify a specific duration. The default duration ends when your session ends. Also, you can perform an OCIDurationEnd
operation which frees all OCIDuration
contents.
Temporary LOBs are especially useful when you want to perform transformational operations on a LOB -- such as morphing an image, or changing a LOB
from one format to another -- and then return it to the database.
These transformational operations can use LOB
Buffering. You can specify CACHE,NOCACHE,or CACHE READS
for each temporary LOB
, and FREE
an individual temporary LOB
when you have no further need for it.
Your temporary tablespace is used to store temporary LOB
data. Data storage resources are controlled by the DBA through control of a user's access to temporary tablespaces, and by the creation of different temporary tablespaces.
Memory usage increases incrementally as the number of temporary LOB
s grows. You can reuse temporary LOB
space in your session by freeing temporary LOB
s explicitly.
LOB
s does not result in all of the space being returned to the temporary tablespace for general re-consumption. Instead, it remains available for reuse in the session.
LOB
s is freed along with the deletion of the temporary LOBs. In all cases, when a user's session ends, space is returned to the temporary tablespace for general reuse.
We previously noted that if you perform the following:
SELECT
permanent_lob
INTOtemporary_lob_locator
FROM y_blah
WHERE x_blah
the temporary_lob_locator
will get overwritten with the permanent_lob
's locator. The temporary_lob_locator now points to the LOB stored in the table.
Since CR and rollbacks are not supported for temporary LOB
s, you will have to free the temporary LOB
and start over again if you run into an error.
Creation of a temporary LOB
instance by a user causes the engine to create, and return a locator to LOB
data. Temporary LOB
s do not support any operations that are not supported for persistent LOB
locators, but temporary LOB
locators have specific features.
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|