kubo / ruby-oci8

Ruby-oci8 - Oracle interface for ruby
Other
169 stars 75 forks source link

Using bolean bind variables #103

Closed GPardal closed 9 years ago

GPardal commented 9 years ago

Hey there,

I'm trying to use bind variables to get the output of a SQL procedure. However, one of the output variables (:out_result) is a Bolean. I've tried to do something like:

out_error_ctl = ' '*4000
out_result = true
query1 = <<-SQL.gsub(/^\s*/, '')
      BEGIN
         RetVal := #{db_info[:schema]}.#{db_info[:procedure]}.reload(
                         ....input vars....
                        outerrorctl  => :out_error_ctl,
                        outresult    => :out_result);
      END;
    SQL

...
@dbh.exec(query1, out_error_ctl, out_result)

The thing is, the out_result variable in Ruby is a TrueClass, and not a bolean as the PL/SQL accepts it. I get the following error:

unsupported datatype: TrueClass

I've been reading the documentation, and found nothing regarding a Bolean type defined by Ruby-Oci8. No searches have returned this use case, and I'm quite lost at what to do. I've even tried to set out_result = ' '*4000 and in the PL/SQL block declaring :out_result BOOLEAN;, but then I get the following error:

PLS-00103: Encountered the symbol "" when expecting one of the following:

Does any one have any ideas how to solve this problem?

Thanks for the help.

kubo commented 9 years ago

Ruby-oci8 doesn't support PL/SQL boolean yet. I have no good workaround idea. I'll fix it later.

Well, if you use Oracle client earlier than 12c, it is unable to fix it. PL/SQL boolean type in OCI is supported since 12c.

GPardal commented 9 years ago

Hey kubo.

That's sad to hear but at least now I now it's futile to try to make it work.

Again, thanks for the quick and helpful replies, and your great work with this gem.

Cheers!

kubo commented 9 years ago

Ruby-oci8 2.2.1 was released. It supports boolean type binding if both Oracle server and client versions are 12c.