Oracle - PL/SQL - TO_LOB Function

TO_LOB converts LONG or LONG RAW values in the column long_column to LOB values. You can apply this function only to a LONG or LONG RAW column, and only in the select list of a subquery in an INSERT statement.


Before using this function, you must create a LOB column to receive the converted LONG values. To convert LONG values, create a CLOB column. To convert LONG RAW values, create a BLOB column.


You cannot use the TO_LOB function to convert a LONG column to a LOB column in the subquery of a CREATE TABLE ... AS SELECT statement if you are creating an index-organized table. Instead, create the index-organized table without the LONG column, and then use the TO_LOB function in an INSERT ... AS SELECT statement.

The syntax for the to_lob function is:

to_lob( long_column )

long_column can be a LONG or LONG RAW value.

Applies To:

· Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g

For example:

insert into companies (lob_column)
select to_lob(long_column)
from suppliers;

This example would convert the value in the field called long_column to a LOB value.