2 Replies Latest reply on May 6, 2014 3:31 AM by Kutir Mobility

    invalid byte sequence UTF-8

    Alexey Mironov

      Hello,

      I have some trouble with updating/insert in my rhoconnect controller -

       

      #coding: utf-8
      require 'oci8

       

      class Users < SourceAdapter

        def initialize(source, argtw

          f = File.new(Dir.pwd + "/settings/config.txt")

          i = 0

          f.each do |line|

            if (i.to_i == 0)        

              @conn = line.chop

            end 

            i = i.to_i + 1

          end

          f.close 

          @client = OCI8.new(@conn)

          super(source)

        end

       

        def login

        end

       

        def query(params=nil)

          puts "Users"

          sql = 'SELECT ID,NAME,PIN FROM VW_RPT_VOZ_TCD_USERS'  

          @result={}

          @client.exec("BEGIN DBMS_SESSION.SET_CONTEXT('CLIENTCONTEXT', 'TCD', '" +  params['device_id'].to_s + "'); END;") 

          @client.commit     

          @client.exec(sql) do |row|

            inventlocation = {}

            inventlocation["ID"] = row[0]

            inventlocation["NAME"] = row[1].encode('utf-8') 

            inventlocation["PIN"] = row[2].encode('utf-8')                                                        

            @result[row[0].to_s] = inventlocation  

          end      

        end

       

        def sync

          super

        end

       

        def create(create_hash)

        end

       

        def update(update_hash)    

          puts "User update"

          cursor = @client.parse("begin Z$VOZ_INK_TCD_USER_Lupdate_rec(" + update_hash["id"].to_s + ",'" + update_hash["PIN"].to_s + "'); end;")

          cursor.exec

          @client.commit

        end

       

        def delete(delete_hash)

        end

       

        def logoff

        end

       

      end

       

      Download work so good, but when I change fields value in "Users" and call Sync again have some error in log:

       

      [10:52:10 AM 2014-05-05] invalid byte sequence in UTF-8/opt/rhoconnect/lib/ruby/gems/2.1.0/gems/rhoconnect-3.3.2/lib/rhoconnect.rb:203:in `split'

       

      i.e. def update(update hash) is not calling, and error hapend before!!!

       

      What can I do?