Original code:
require 'oci8'
SCHEDULER.every '10s', :first_in => 0 do |job|
begin
conn = OCI8.new('apps','apps');
mylist = Hash.new
conn.exec("select full_name, count(*) from per_all_people_f
where rownum < 6 group by first_name") do |r|
mylist[r[0]] = { label: r[0], value: r[1].to_i.to_s }
end
send_event('emp-list', { items: mylist.values })
conn.logoff
rescue Exception => e
puts e.message
end
end
Running ruby oratest1.rb
gives following errors:
oratest1.rb:11: syntax error
mylist[r[0]] = { label: r[0], value: r[1].to_i.to_s }
^
oratest1.rb:11: syntax error
mylist[r[0]] = { label: r[0], value: r[1].to_i.to_s }
^
oratest1.rb:11: syntax error
oratest1.rb:13: syntax error
send_event('emp-list', { items: mylist.values })
^
oratest1.rb:13: syntax error
send_event('emp-list', { items: mylist.values })
^
oratest1.rb:17: syntax error
rescue Exception => e
^
oratest1.rb:21: syntax error
You are probably using ruby 1.8. This hash syntax was included on 1.9 onwards.
To make sure, run ruby -v and check the output.