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 R.

On Thu, Oct 22, 2009 at 11:05 AM, Rafael R.
[email protected] wrote:

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;…

How could I fetch the value of the RESULTV and RESULTBC variables?

Doesn’t that return a resultset?


Hassan S. ------------------------ [email protected]
twitter: @hassan

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

On Thu, Oct 22, 2009 at 11:37 AM, Rafael R.
[email protected] wrote:

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,

Hassan S. ------------------------ [email protected]
twitter: @hassan

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

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.

On Oct 22, 2:43 pm, Hassan S. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs