Convert OCI8 SQL Results to JSON

Hi Experts,

I would like to seek your assistance on how to convert my SQL results to JSON. Below is my .rb code and the results I want to convert

#! /usr/bin/env ruby

require ‘oci8’

require ‘json’

#Create a connection to the Oracle Database

oci = OCI8.new(‘GLOGOWNER’,‘Sh#reit1’,‘192.168.30.223:1521/orcl’)

#parse and exec the statement

cursor = oci.parse(‘select shipment_gid,total_actual_cost, total_actual_cost_base, start_time from shipment where rownum <= 3’)

cursor.exec

#output column names

#puts cursor.getColNames.join(",")

#output rows

#while r = cursor.fetch

puts r.join(",")

#end

hashes = cursor.collect { |ro|

ro.to_json

}

JSON.generate(hashes)

#close the cursor

cursor.close

oci.logoff

puts ‘-’*80

``

Warning: NLS_LANG is not set. fallback to US7ASCII. SHIPMENT_GID,TOTAL_ACTUAL_COST,TOTAL_ACTUAL_COST_BASE,START_TIME DEMO.01064,0.3e4,0.29570999999999999090505298227071762085e4,2016-05-02 09:00:00 +0000 GSK.01136,0.0,0.0,2016-05-22 09:18:00 +0000 DEMO.01066,0.2e4,0.19714000000000000909494701772928237915e4,2016-05-02 13:10:00 +0000

``

Unfortunately I get the error below

Warning: NLS_LANG is not set. fallback to US7ASCII. /opt/sensu/embedded/bin/dbconnect.rb:19:in <main>': undefined methodcollect’ for #OCI8::Cursor:0x000000007e8d80 (NoMethodError)

``

Any ideas on how to do the conversion properly?

Regards,

Peter