Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting BLOB data to CLOB 1

Status
Not open for further replies.

Shantha

Programmer
Jun 12, 2002
48
IN
Hi,

I am facing problems in populating the data from a BLOB field to a CLOB field.

Could somebody help in this regards.

Shantha.

Talent is what you possess;
genius is what possesses you

 
Hello Shantha

By using the UTL_RAW Oracle built-in package, available with Oracle PL/SQL 8 or higher.

Example:

drop table test_blob
Table dropped

drop table test_clob
Table dropped

CREATE TABLE test_blob (c1 NUMBER,
c2 BLOB)
Table created

CREATE TABLE test_clob (c1 NUMBER,
c2 CLOB)
Table created

INSERT INTO test_blob
VALUES (1, '48656C6C6F' || UTL_RAW.cast_to_raw (' there!'))
1 row inserted


select * from test_blob
C1 C2
---------- -----------
1 <BLOB>

1 row selected


INSERT INTO test_clob
VALUES (1, 'Some data for record 1.')
1 row inserted


select * from test_clob
C1 C2
---------- ----------------------------------------
1 Some data for record 1.

1 row selected


insert into test_clob
select 2, UTL_RAW.cast_to_varchar2(c2)
from test_blob
where c1 = 1
1 row inserted


select * from test_clob
C1 C2
---------- ----------------------------------------
1 Some data for record 1.
2 Hello there!

2 rows selected

Hope this helps.

Regards

TheOracleGuy


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top