Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsupported typecode opaque #215

Open
robin1607 opened this issue May 27, 2019 · 4 comments
Open

unsupported typecode opaque #215

robin1607 opened this issue May 27, 2019 · 4 comments

Comments

@robin1607
Copy link

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)>'`
@kubo
Copy link
Owner

kubo commented May 27, 2019

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

@robin1607
Copy link
Author

robin1607 commented May 28, 2019

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

@kubo
Copy link
Owner

kubo commented May 28, 2019

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.

@robin1607
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants