| Oracle9i Application Developer's Guide - Large Objects (LOBs) Release 1 (9.0.1) Part Number A88879-01 |
|
Temporary LOBs, 3 of 29
Oracle9i supports the definition, creation, deletion, access, and update of temporary LOBs in the following programmatic environments or "interfaces":
DBMS_LOB package
PRO*C precompiler
OCI
The 'interfaces' listed above, operate on temporary LOBs through locators in the same way that they do for permanent LOBs. 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 LOBs 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:
SELECTpatternFROMcomposite_image WHERE temp_lob_pattern_id =somepattern_match_function(lobvalue);
SELECTPermanentLobINTOTemporaryLob_loc FROM Demo_tab WHERE Column1 := 1;
Compare the use case model diagrams for temporary LOBs with the Figure 11-1, "Use Case Model Diagram: Internal Temporary LOBs (part 1 of 2)", and Figure 11-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 (OCILobLocatorAssign, OCILobLocatorIsInit, and so on).
In addition, you can use the ISTEMPORARY function to determine if a LOB is temporarily based on its locator.
The DBMS_LOB.createtemporary() call takes a duration parameter. This parameter is merely a hint and is not strictly enforced.
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 LOBs are not associated with table schema, there is no meaning to the terms "inline" and "out-of-line" for temporary LOBs.
The default lifetime of a temporary LOB is a session.
The interface for creating temporary LOBs includes a parameter that lets you specify the default scope of the life of the temporary LOB. By default, all temporary LOBs are deleted at the end of the session in which they were created. If a process dies unexpectedly or the database crashes, all temporary LOBs are deleted.
OCI users can group temporary LOBs together into a logical bucket.
"OCIDuration" represents a store for temporary LOBs. There is a default duration for every session into which temporary LOBs 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 that 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 LOBs grows. You can reuse temporary LOB space in your session by freeing temporary LOBs explicitly.
LOBs 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.
LOBs 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:
SELECTpermanent_lobINTOtemporary_lob_locatorFROM y_blahWHERE 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 LOBs, 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 LOBs do not support any operations that are not supported for persistent LOB locators, but temporary LOB locators have specific features.
|
|
![]() Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|