2010-07-12 35 views
3

我有使用activerecord從數據庫訪問數據。它在localhost中正常工作,但當我嘗試它時另一臺服務器,我收到以下錯誤:ActiveRecord :: StatementInvalid(Mysql :: Error:PROCEDURE db_name.proc_spName無法返回給定上下文中的結果集:

ActiveRecord::StatementInvalid (Mysql::Error: PROCEDURE db_name.proc_spName can't return a result set in the given context: CALL proc_spName(............)): 
    /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:188:in `log' 
    /vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:310:in `execute' 
    /app/controllers/keywordprocessor_controller.rb:306:in `result' 
    /vendor/rails/actionpack/lib/action_controller/base.rb:1256:in `send' 

BTW,下面是我遇到下面的錯誤

sql = "CALL proc_getresults" 
res = ActiveRecord::Base.connection.execute(sql) 

任何想法,將不勝感激行..

+1

有可能是有用的答案類似的問題被問已經在這裏:http://stackoverflow.com/questions/471517/is-it-possible-to-call-a-mysql-stored-procedure-from -紅寶石 – bjg 2010-07-12 11:21:12

回答

2

由於BJG告訴你,這個鏈接很好解釋它;因爲ActiveRecord期望返回結果集。你可以沿着這些行使用execute來調用存儲過程。

SELECT proc_getresults() as Results FROM TABLE ... 
相關問題