【问题标题】:rails executing stored procedure errorrails执行存储过程错误
【发布时间】:2015-03-20 19:23:29
【问题描述】:

我有一个 oracle 存储过程。

当我尝试在 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;

但是当我尝试在 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);

不确定以上是否有效。

【问题讨论】:

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


    【解决方案1】:

    此行缺少结束)

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

    应该是:

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

    【讨论】:

      猜你喜欢
      • 2023-03-13
      • 1970-01-01
      • 2017-07-20
      • 2013-04-12
      • 2016-10-12
      • 1970-01-01
      • 1970-01-01
      • 2021-08-31
      • 1970-01-01
      相关资源
      最近更新 更多