ruby-oci8 icon indicating copy to clipboard operation
ruby-oci8 copied to clipboard

unsupported typecode opaque

Open robin1607 opened this issue 6 years ago • 4 comments

I'm getting 'unsupported typecode opaque' error when calling function which returns oracle json_object or json_array.

 `     RuntimeError:
   unsupported typecode opaque
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-oci8-2.2.7/lib/oci8/object.rb:529:in `check_metadata'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-oci8-2.2.7/lib/oci8/object.rb:546:in `initialize'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-oci8-2.2.7/lib/oci8/object.rb:400:in `new'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-oci8-2.2.7/lib/oci8/object.rb:400:in `block in initialize_named_type'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-oci8-2.2.7/lib/oci8/object.rb:399:in `collect'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-oci8-2.2.7/lib/oci8/object.rb:399:in `initialize_named_type'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-oci8-2.2.7/lib/oci8/object.rb:388:in `initialize'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-oci8-2.2.7/lib/oci8/object.rb:27:in `new'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-oci8-2.2.7/lib/oci8/object.rb:27:in `get_tdo_by_class'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-oci8-2.2.7/lib/oci8/cursor.rb:495:in `make_bind_object'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-oci8-2.2.7/lib/oci8/cursor.rb:104:in `bind_param'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-plsql-0.7.1/lib/plsql/oci_connection.rb:104:in `bind_param'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-plsql-0.7.1/lib/plsql/procedure_call.rb:23:in `block in exec'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-plsql-0.7.1/lib/plsql/procedure_call.rb:22:in `each'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-plsql-0.7.1/lib/plsql/procedure_call.rb:22:in `exec'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-plsql-0.7.1/lib/plsql/procedure.rb:266:in `exec'
 # /Users/usr/.rvm/gems/ruby-2.6.3/gems/ruby-plsql-0.7.1/lib/plsql/package.rb:67:in `method_missing'
 # ./spec/Packages/test/mytest.rb:41:in `block (3 levels) in <top (required)>'`

robin1607 avatar May 27 '19 14:05 robin1607

@robin1607 Could you post sample code to reproduce the issue?

kubo avatar May 27 '19 23:05 kubo

PLSQL:

create or replace package testpackage as

function exampleFunction
    return json_object_t;

end testpackage;


create or replace package body testpackage as

function exampleFunction
return json_object_t
is
    example_json_object      json_object_t;
begin
    example_json_object := new json_object_t;
    example_json_object.put('testkey', 'testvalue');
    return example_json_object;
end exampleFunction;

end testpackage;
/

Ruby:

json_object = plsql.testpackage.exampleFunction # Throws Error
puts json_object

robin1607 avatar May 28 '19 06:05 robin1607

Could you change the return type from json_objec_t to varchar2 or clob?

Ruby-oci8 converts object type attribute values to ruby values. However there are no methods to convert opaque types. This issue will be fixed by redesign of object type support, which I have had in mind since decade ago, though I have not noticed the opaque type issue. Well, the priority is low for me as long as there are workarounds.

kubo avatar May 28 '19 14:05 kubo

Thanks for your answer. We have already thought about the workarounds, but for unit tests of small methods we would have to change our clear and structured system design of JSON handling. So the workarounds are not the best solution for us.

I understand the the redesign of object types has a low priority so we will find another way.

robin1607 avatar May 29 '19 07:05 robin1607