ITPub博客

首页 > Linux操作系统 > Linux操作系统 > How to Convert LONG to a CLOB [ID 282464.1]

How to Convert LONG to a CLOB [ID 282464.1]

原创 Linux操作系统 作者:spider0283 时间:2012-05-20 00:56:05 0 删除 编辑
Checked for relevance on 28-OCT-2009

PURPOSE
-------

How-To convert a LONG column to a CLOB to perform. substring operations on the 
data.
 
SCOPE & APPLICATION
-------------------

VB, C/C++, Java, PL/SQL, stored procedure developers

How-To convert a LONG column to a CLOB
---------------------------------------
 

There is no supplied fuction to perform. substring operations directly on LONG 
columns. However, such functions are possible with CLOB type columns.
DBMS_LOB.Copy() function can copy all or part of a source internal CLOB  to a 
CLOB or BLOB to a BLOB. You can specify the offset for both the source and 
destination LOB ( CLOB or BLOB ), and the number of bytes or characters to copy.

Now, there is function that coverts a LONG to CLOB. 

With version 8.1.X and later the TO_LOB function can be used to
convert data stored in longs and long raws to CLOBs and BLOBs respectively.

This function works fine in SQL*Plus when used as follows:

   create table long_data (a number, b long);
   create table clob_data (a number, b clob);

   insert into long_data values (1, 'Long data to be converted to clob');

   insert into clob_data select a, to_lob(b) from long_data;

   select * from clob_data;

   A B
   --------------------------------------------------------------
   1    Long data to be converted to clob

With a long raw data, the function goes as 

   create table long_data (a number, b long raw);
   create table blob_data (a number, b blob);

   insert into long_data values (1, utl_raw.cast_to_raw('Long data to be converted to clob'));

   insert into blob_data select a, to_lob(b) from long_data;


RELATED DOCUMENTS
-----------------


返回页首返回页首

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/38267/viewspace-730269/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-03-29

  • 博文量
    194
  • 访问量
    609630