 |
Forums |
Admin Start New Thread
By: Philip Nelson
RE: Guide for the driver [ reply ] 2008-02-25 22:19
|
I got this partially working.
Here's my code -
def create
porder = '<FoxOrder/>'
conn = Order.connection.connection
sql = "call DBFOX001.SP004PUBLIC_ORDER(?,?)"
stmt = IBM_DB::prepare(conn,sql)
@preply = nil
IBM_DB::bind_param(stmt,1,"porder",IBM_DB::SQL_PARAM_INPUT)
IBM_DB::bind_param(stmt,2,"@preply",IBM_DB::SQL_PARAM_OUTPUT)
IBM_DB::execute(stmt)
@preply
end
All seems to be fine until the execute : then I get ...
ArgumentError (NULL pointer given):
/home/pnelson/work/floralsource/rails/floralsource/branches/order_entry_fix/app/controllers/purchases_controller.rb:50:in `execute'
Any clues ?
Phil
|
By: Antonio Cangiano
RE: Guide for the driver [ reply ] 2008-02-22 23:49
|
Hi Phil,
you can try the following (off the top of my head, I haven't tested it with an XML based stored procedure).
Your model:
class MyModel < ActiveRecord::Base
def self.public_order(porder)
conn = connection.connection
sql = "CALL MYSCHEMA.SP004PUBLIC_ORDER(?, ?)"
stmt = IBM_DB::prepare(conn, sql)
preply = ""
IBM_DB::bind_param(stmt, 1, "porder", IBM_DB::PARAM_IN)
IBM_DB::bind_param(stmt, 2, "preply", IBM_DB::PARAM_OUT)
IBM_DB::execute(stmt)
return preply
end
end
From your controller:
@my_data = MyModel.public_order(porder)
|
By: Philip Nelson
RE: Guide for the driver [ reply ] 2008-02-22 22:30
|
Antonio,
Thanks for the very timely post.
This covers the driver directly from Ruby. I need a little bit of help translating this into Rails use.
I've got a need to call a stored procedure in Rails which takes two parameters (one input, the other output and both being XML columns) -
CREAT PROCEDURE MYSCHEMA.SP004PUBLIC_ORDER
( IN pOrder XML
, OUT pReply XML) ...
Would you be able to show me how to do this ?
Thanks
Phil
|
|
 |