long2varchar 把long轉換為varchar2

raysuen發表於2018-11-11

發文的主要原因是因為前幾天一個同事一直說獲取分割槽表的high_value不會,並且一直表示long型別完全不能獲取。迫不得已,我今晚查了一下資料,發現oracle本身有對long型別的轉換支援。


SQL> desc dbms_metadata_util

…...

FUNCTION LONG2VARCHAR RETURNS VARCHAR2

Argument Name                  Type                    In/Out Default?

------------------------------ ----------------------- ------ --------

LENGTH                         NUMBER                  IN

TAB                            VARCHAR2                IN

COL                            VARCHAR2                IN

ROW                            ROWID                   IN

…...

create table t1 (name long);

insert into t1 values(‘a’);

insert into t1 values(‘b’);

insert into t1 values(‘c’);

commit;

SQL> select sys.dbms_metadata_util.long2varchar(100,'scott.t1','name',rowid) from scott.t1;

SYS.DBMS_METADATA_UTIL.LONG2VARCHAR(100,'SCOTT.T1','NAME',ROWID)

--------------------------------------------------------------------------------

a

b

c

SQL>  select * from scott.t1 where sys.dbms_metadata_util.long2varchar(100,'scott.t1','name',rowid) = 'a';

NAME

--------------------------------------------------------------------------------

a




來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28572479/viewspace-2219552/,如需轉載,請註明出處,否則將追究法律責任。

相關文章