简体   繁体   English

Rails执行存储过程错误

[英]rails executing stored procedure error

I have a oracle stored procedure. 我有一个oracle存储过程。

When I try to run the following in sql developer it works fine: 当我尝试在sql developer中运行以下命令时,效果很好:

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;

But when I try to run the above code in rails 3 as follows: 但是当我尝试在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

I get the following error: 我收到以下错误:

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

Any ideas? 有任何想法吗?

I even tried: 我什至尝试:

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

Not sure if the above is valid. 不确定以上内容是否有效。

This line is missing the closing ) : 该行缺少结尾)

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

It should be: 它应该是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM