Sequel访问Oracle CLOB

修改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
 

你可能感兴趣的:(oracle,sql,C++,c,C#)