CREATE OR REPLACE FUNCTION LONG_TO_CHAR( in_rowid rowid,in_owner varchar,in_table_name varchar,in_column varchar2) RETURN varchar AS text_c1 varchar2(32767); sql_cur varchar2(2000); -- begin sql_cur := 'select '||in_column||' from '||in_owner||'.'||in_table_name||' where rowid = '||chr(39)||in_rowid||chr(39); dbms_output.put_line (sql_cur); execute immediate sql_cur into text_c1; text_c1 := substr(text_c1, 1, 4000); RETURN TEXT_C1; END;
测试
select LONG_TO_CHAR(ROWID,'USERNAME','TABLE','COLUMN') from TABLE