Get return from oracle procedure

Hi all, I have a procedure in which I pass two integers and two dates and get two integer as the result.How could I read the response with ROR?

Here´s my code: ActiveRecord::Base.connection.execute("DECLARE RESULTV NUMBER; RESULTBC NUMBER; BEGIN PODEVIAJAR(112,to_date('21/10/2009','DD/MM/YYYY'),to_date('22/10/2009','DD/MM/YYYY'),RESULTV,RESULTBC,26112); END;")

How could I fetch the value of the RESULTV and RESULTBC variables? Thanks, Rafael Roque

Doesn't that return a resultset?

It should return me two integers,but it´s returning "1".

It should return me two integers,but it´s returning "1".

OK, sorry -- I don't know anything about Oracle procedures, but if I execute a query using ActiveRecord::Base.connection.execute(sql) it returns a resultset, e.g. (via script/console)

result = ActiveRecord::Base.connection.execute("select 1")

=> #<Mysql::Result:0x1fe43a8>

result.fetch_row

=> ["1"]

HTH,

This doesn’t answer your question directly, but you might want to read about how to obtain Oracle debug output in your Rails app/log file:

http://www.alexrothenberg.com/2009/08/how-to-capture-oracles-dbmsoutput-in.html

I believe Alex’s patch was recently added to the Oracle Enhanced Adapter... if you’re using that and upgrade to the latest version that includes the patch, you’ll be able to put some debug/log code in your PL/SQL and get maybe get some idea of what’s going on.

- pat http://patshaughnessy.net

I believe the problem that oracle procedures do not return a value (oracle defines procedures and functions differently).

The easiest way to interact with PLSQL procedures is to use the plsql gem http://ruby-plsql.rubyforge.org/ or http://github.com/rsim/ruby-plsql. Read through the ruby-plsql documentation to see exactly how to use it but it will be something like:

# you could name the argurments with :a_number=>112, :start_date=>'21/10/2009' etc. based on the parameters of podeviajar result = plsql.podeviajar(112, '21/10/2009', '22/10/2009', 1, 1,26112); puts result[:RESULTV] puts result[:RESULTBC]

Hope this helps Alex