select_hash_first select_hash_all is supported in jruby?

27 views
Skip to first unread message

Diego Alvarez Zuluaga

unread,
Dec 7, 2012, 4:00:54 PM12/7/12
to oracle-...@googlegroups.com
Hi

I´m trying to use select_hash_first in ruby-plsql but i'm getting this error:

plsql.select_hash_first("SELECT 'abc' a, 123 b, 123.456 c from dual")

ArgumentError: No database object 'SELECT_HASH_FIRST' found
        from c:/ruby/jruby-1.7.1/lib/ruby/gems/shared/gems/ruby-plsql-0.5.0/lib/plsql/schema.rb:182:in `method_missing'
        from (irb):22:in `evaluate'
        from org/jruby/RubyKernel.java:1066:in `eval'
        from org/jruby/RubyKernel.java:1392:in `loop'
        from org/jruby/RubyKernel.java:1174:in `catch'
        from org/jruby/RubyKernel.java:1174:in `catch'
        from c:/ruby/jruby-1.7.1/bin/jirb:13:in `(root)'

I'm using jruby 1.7.1, jdk 1.7. 

 select_hash_first is supported in jruby?

This is the test of ruby-plsql that show the use of select_hash_first

 it "should execute SQL statement and return first result as hash" do
      @now = Time.local(2008,05,31,23,22,11)
      @conn.select_hash_first("SELECT 'abc' a, 123 b, 123.456 c,
TO_DATE('#{@now.strftime("%Y-%m-%d %H:%M:%S")}', 'YYYY-MM-DD HH24:MI:SS') d
FROM dual").should == {:a => "abc", :b => 123, :c => 123.456, :d => @now}
    end

Thanks in advance

Yasuo Honda

unread,
Dec 10, 2012, 7:46:14 AM12/10/12
to oracle-...@googlegroups.com
Hi,

Yes. A unit test for the `select_hash_first` has passed as follows.

$ java -version
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)

$ jruby -v
jruby 1.7.1 (1.9.3p327) 2012-12-03 30a153b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_09-b05 [linux-amd64]

$ rspec ./spec/plsql/connection_spec.rb 
......./home/yahonda/git/ruby-plsql/spec/plsql/connection_spec.rb:146 warning: ambiguous Java methods found, using java.math.BigDecimal(long)
..................................

Finished in 4.91 seconds
41 examples, 0 failures


Raimonds Simanovskis

unread,
Dec 11, 2012, 3:01:16 AM12/11/12
to oracle-...@googlegroups.com
If you want to use this method then you need to call it like

plsql.connection.select_hash_first("SELECT 'abc' a, 123 b, 123.456 c from dual")

But this method is internal ruby-plsql API, I would recommend to use

plsql.select(:first, "SELECT 'abc' a, 123 b, 123.456 c from dual")

Diego Alvarez Zuluaga

unread,
Dec 13, 2012, 2:53:29 PM12/13/12
to oracle-...@googlegroups.com
tks

And Raimonds.. you are the best! thanks for all your work!
Reply all
Reply to author
Forward
0 new messages