当前位置: 首页 > 工具软件 > Sequel Ace > 使用案例 >

Sequel访问Oracle CLOB

司空炯
2023-12-01

修改oracle.rb中的fetch_rows,原代碼:

      def fetch_rows(sql)
        execute(sql) do |cursor|
          begin
            @columns = cursor.get_col_names.map{|c| output_identifier(c)}
            while r = cursor.fetch
              row = {}
              r.each_with_index {|v, i| row[@columns[i]] = v unless @columns[i] == :raw_rnum_}
              yield row
            end
          ensure
            cursor.close
          end
        end
        self
      end

 修改后:

      def fetch_rows(sql, &block)
	      execute(sql) do |cursor|
          begin
            @columns = cursor.get_col_names.map {|c| c.downcase.to_sym}
            while r = cursor.fetch
              row = {}
              r.each_with_index do |v, i|
                puts "CLASS: #{v.class}"
                if v.class == OCI8::CLOB
                  puts "Caught CLOB!"
                  row[columns[i]] = v.read
                else
                  row[columns[i]] = v unless columns[i] == :raw_rnum_
                end
              end
              yield row
            end
          ensure
            cursor.close
          end
        end

      end
 
 类似资料: