begin dbms_output.enable(20000); crs := dbms_sql.open_cursor; dbms_sql.parse(crs ,'select text from dba_views where view_name=''DBA_USERS''' ,dbms_sql.v7); dbms_sql.define_column_long(crs,1); prsd := dbms_sql.execute_and_fetch(crs); dbms_sql.column_value_long(crs ,1 ,str_len ,str_start -1 ,outval ,outval_length); dbms_sql.close_cursor(crs); outval := translate(outval,CHR(10),' '); dbms_output.put_line(outval); end;
方法二 declare /* Modify the SQL in cursor v_cur and take out the test ROWNUM code. */ cursor v_cur is select rowidtochar(rowid) c_rowid, DCONTENT l_longraw from tst03 where rownum < 100;
v_max_length number :=0; v_length number :=0; v_rowid varchar(18) := ' ';
begin for v_row in v_cur loop v_length := lengthb(v_row.l_longraw); if v_length > v_max_length then v_max_length := v_length; v_rowid := v_row.c_rowid; end if; end loop; dbms_output.put('RowID: '||v_rowid||' Max Length: '||v_max_length); dbms_output.new_line; end;
方法三,用copy命令 set long 30000 copy to /@ - insert - (columns in destination table),- from