• Clob对象转换为String


      /**
         * @title: clobParseString
         * @description:TODO Clob对象转换为String
         * @author: yubo  
         * @param clob
         * @return
         * @throws SQLException
         * @date:2016-1-6下午4:01:42
         */
        public static String clobParseString(Clob clob) throws SQLException{
            String result = "";
            if(clob != null){
                result = clob.getSubString((long)1,(int)clob.length());
            }
            return result;
        }

     行转列oracle:

    create or replace type type_concatstr_clob as object
    (
      total  clob,
      static function ODCIAggregateInitialize(sctx IN OUT type_concatstr_clob) return number,
      member function ODCIAggregateIterate(self IN OUT type_concatstr_clob,value IN clob) return number,
      member function ODCIAggregateTerminate(self IN type_concatstr_clob,returnValue OUT clob,flags IN number) return number,
      member function ODCIAggregateMerge(self IN OUT type_concatstr_clob,ctx2 IN type_concatstr_clob) return number
    )
    /
    
    create or replace type body type_concatstr_clob
    is
      --在concatstr的基础上改写
      static function ODCIAggregateInitialize(sctx IN OUT type_concatstr_clob) return number
      is
      begin
        sctx := type_concatstr_clob(null);
        return ODCIConst.Success;
      end;
    
      member function ODCIAggregateIterate(self IN OUT type_concatstr_clob,value IN clob) return number
      is
      begin
        self.total := self.total || ',' || value;
        return ODCIConst.Success;
      end;
    
      member function ODCIAggregateTerminate(self IN type_concatstr_clob,returnValue OUT clob,flags IN number) return number
      is
      begin
        returnValue := ltrim(self.total,',');
        return ODCIConst.Success;
      end;
    
      member function ODCIAggregateMerge(self IN OUT type_concatstr_clob,ctx2 IN type_concatstr_clob) return number
      is
      begin
        self.total := self.total || ctx2.total;
        return ODCIConst.Success;
      end;
    end;
    /
    create or replace function f_concatstr_clob(input varchar2) return clob
      parallel_enable
      aggregate using type_concatstr_clob;

    For example:

    SELECT u.c_agencyname FROM (
    SELECT f_concatstr_clob(e.c_agencyno||':'||e.c_agencyname) c_agencyname FROM   tagencyinfo e) u ;
  • 相关阅读:
    写入和读取本地文件。
    通过ADG技术迁移单实例到rac集群上
    更改整个目录文件的所有权限
    oracle12c安装过程netca报错failed to core dump
    oracle通过闪回查询表的更改记录
    oracle表空间使用率查询sql
    SQL执行慢的原因分析
    存储过程+定时job
    oracle goldengate搭建配置
    oracle11G Windows冷备恢复
  • 原文地址:https://www.cnblogs.com/Lightning-Kid/p/5106118.html
Copyright © 2020-2023  润新知