Oracle9i Application Developer's Guide - Large Objects (LOBs) Release 1 (9.0.1) Part Number A88879-01 |
|
Internal Persistent LOBs, 8 of 43
See:
"Use Case Model: Internal Persistent LOBs Operations", for all Internal Persistent LOB operations. |
This procedure describes how to insert a LOB value using EMPTY_CLOB() or EMPTY_BLOB().
Here are guidelines for inserting LOBs:
Before you write data to an internal LOB
, make the LOB
column non-null; that is, the LOB column must contain a locator that points to an empty or populated LOB
value. You can initialize a BLOB
column's value by using the function EMPTY_BLOB
() as a default predicate. Similarly, a CLOB
or NCLOB
column's value can be initialized by using the function EMPTY_CLOB
().
You can also initialize a LOB column with a character or raw string less than 4,000 bytes in size. For example:
INSERT INTO Multimedia_tab (clip_id, story) VALUES (1,'This is a One Line Story');
You can perform this initialization during CREATE
TABLE
(see "Creating a Table Containing One or More LOB Columns") or, as in this case, by means of an INSERT
.
See Chapter 3, "LOB Support in Different Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:
See:
Appendix B, "The Multimedia Schema Used for Examples in This Manual" for a description of the multimedia application and table |
Examples are provided in the following programmatic environments:
These functions are special functions in Oracle SQL, and are not part of the DBMS_LOB
package.
/* In the new row of table Multimedia_tab, the columns STORY and FLSUB are initialized using EMPTY_CLOB(), the columns FRAME and SOUND are initialized using EMPTY_BLOB(), the column TRANSSCRIPT in the nested table is initialized using EMPTY_CLOB(), the column DRAWING in the column object is initialized using EMPTY_BLOB(): */ INSERT INTO Multimedia_tab VALUES (1, EMPTY_CLOB(), EMPTY_CLOB(), NULL, EMPTY_BLOB(), EMPTY_BLOB(), NULL, InSeg_tab(InSeg_typ(1, NULL, 'Ted Koppell', 'Jimmy Carter', NULL, EMPTY_CLOB())), NULL, Map_typ('Moon Mountain', 23, 34, 45, 56, EMPTY_BLOB(), NULL)); /* In the new row of table Voiceover_tab, the column SCRIPT is initialized using EMPTY_CLOB(): */ INSERT INTO Voiceover_tab VALUES ('Abraham Lincoln', EMPTY_CLOB(), 'James Earl Jones', 1, NULL);
This script is located at $ORACLE_HOME/rdbms/demo/lobs/java/iinserte.java.
Statement stmt = conn.createStatement() ; try { stmt.execute ("insert into lobtable values (empty_blob())"); } catch{ ...} Util.trySQL, Util.doSQl below does the stmt.execute() ; Util.trySQL (conn, "drop table lobtran_table"); Util.doSQL (conn, "create table lobtran_table (b1 blob, b2 blob, c1 clob, c2 clob, f1 bfile, f2 bfile)"); Util.doSQL (conn, "insert into lobtran_table values ('010101010101010101010101010101', empty_blob(), 'onetwothreefour', empty_clob(), bfilename ('TEST_DIR', 'tkpjobLOB11.dat'), bfilename ('TEST_DIR', 'tkpjobLOB12.dat'))");
|
![]() Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|