Oracle long字段转varchar

Oracle long字段转varchar

  • 创建函数 long_to_char()


创建函数 long_to_char()

CREATE OR REPLACE FUNCTION long_to_char(in_rowid      ROWID,
                                        in_table_name VARCHAR,
                                        in_column     VARCHAR2)
  RETURN VARCHAR AS
  text_c1 VARCHAR2(32767);
  sql_cur VARCHAR2(2000);
BEGIN
  dbms_output.enable(buffer_size => NULL);
  sql_cur := 'select ' || in_column || ' from ' || 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;

你可能感兴趣的:(Oracle,oracle)