rails执行存储过程错误

时间:2015-03-20 19:23:29

标签: ruby-on-rails oracle ruby-on-rails-3 activerecord

我有一个oracle存储过程。

当我尝试在sql开发人员中运行以下内容时,它可以正常工作:

declare
   vPan varchar2(32);
   ErrorMsg varchar2(32);
   ErrorCode varchar2(32);
   SpErrorMsg varchar2(32);

begin


  DBO_MYDB.PKG_LTD.GET_PAN('8042049440330819','32', 'TEST', '0',vPan, ErrorMsg, ErrorCode, SpErrorMsg);
  DBMS_OUTPUT.PUT_LINE(vPan);

end;

但是当我尝试在rails 3中运行上面的代码时如下:

def number
    errormsg = nil
    errorcode = nil
    sperrormsg = nil
    vpan = nil

    sql =
  "BEGIN #{Pkgltd::PKG_LTD}.GET_PAN('
    8042049440330819','32', 'TEST', '0',vpan, errormsg, errorcode, sperrormsg);
   END;"

   connection = self.connection.raw_connection
   cursor = connection.parse(sql)

     cursor.bind_param(:errormsg, nil, String, 1000)
     cursor.bind_param(:errorcode, nil, String, 1000)
     cursor.bind_param(:sperrormsg, nil, String, 1000
         cursor.bind_param(:vpan, nil, String, 1000)

   cursor.exec

   vpan, errormsg, errorcode, sperrormsg, vpan = cursor[:vpan], cursor[:errormsg], cursor[:errorcode], cursor[:sperrormsg]
   cursor.close
   vpan
end

我收到以下错误:

  

语法错误,意外的tIDENTIFIER,期待')'                            cursor.bind_param(:vpan,nil,String,1000)

有什么想法吗?

我甚至尝试过:

cursor.bind_param(:vpan, nil, varchar2, 1000);

不确定上述内容是否有效。

1 个答案:

答案 0 :(得分:1)

此行缺少结束)

cursor.bind_param(:sperrormsg, nil, String, 1000

应该是:

cursor.bind_param(:sperrormsg, nil, String, 1000)
相关问题