我试图从我的.xsjs文件中调用java中的存储过程。 该过程获得2个输入参数并返回一个。 我可以通过编写来从SQL控制台调用它而没有任何问题:
call "MYSCHEMA"."MyPackage.procedures::addUserC50" ('name', 'lastname', ?)这是我的.xsjs文件中的代码,我认为它在prepareCall语句中失败了。 我尝试了不同的组合(有和没有双引号,有和没有架构/包的名称,有和没有“(?,?,?)”,有和没有“{}”....但没有工作,当我尝试执行它时,我总是得到500内部服务器错误。
有人知道错误的位置或prepareCall方法的确切语法是什么?
var output = 0, query = ""; var conn; var cstmt; try { conn = $.db.getConnection(); query = "{ call \"MYSCHEMA\".\"MyPackage.procedures/addUserC50\"(?,?,?) }"; cstmt = conn.prepareCall(query); // <-- Fails cstmt.setString(1, userName); cstmt.setString(2, userLastname); cstmt.execute(); output = cstmt.getInteger(3); conn.commit(); $.response.status = $.net.http.OK; $.response.setBody("Successfully created: " + output); } catch (e) { $.response.status = $.net.http.BAD_REQUEST; $.response.setBody("0"); } finally { if (cstmt !== null) cstmt.close(); if (conn !== null) conn.close(); }这是给出的错误:InternalError:dberror(Connection.prepareCall):328 - 函数或过程的名称无效:MyPackage.procedures / addUserC50:第1行第18行(位于第17位)ptime / query / checker / check_call。 CC:21
根据这个文档 ,它应该是这样的
var myCallableStatement = myconnection.prepareCall("{call myprocedure(?)}");谢谢
I am trying to call a stored procedure in java from my .xsjs file. The procedure gets 2 input parameters and returns one. I can call it from an SQL console without any problem by writing:
call "MYSCHEMA"."MyPackage.procedures::addUserC50" ('name', 'lastname', ?)This is the code in my .xsjs file, I think that it fails in the prepareCall statement. I have tried different combinations (with and without double quotation marks, with and without the name of the schema/package, with and without "(?,?,?)", with and without "{ }".... But nothing works, I always get the 500 Internal server error when I try to execute it.
Does anybody know where the error is or what is the exact syntax for the prepareCall method?
var output = 0, query = ""; var conn; var cstmt; try { conn = $.db.getConnection(); query = "{ call \"MYSCHEMA\".\"MyPackage.procedures/addUserC50\"(?,?,?) }"; cstmt = conn.prepareCall(query); // <-- Fails cstmt.setString(1, userName); cstmt.setString(2, userLastname); cstmt.execute(); output = cstmt.getInteger(3); conn.commit(); $.response.status = $.net.http.OK; $.response.setBody("Successfully created: " + output); } catch (e) { $.response.status = $.net.http.BAD_REQUEST; $.response.setBody("0"); } finally { if (cstmt !== null) cstmt.close(); if (conn !== null) conn.close(); }This is the error that gives back: InternalError: dberror(Connection.prepareCall): 328 - invalid name of function or procedure: MyPackage.procedures/addUserC50: line 1 col 18 (at pos 17) at ptime/query/checker/check_call.cc:21
According to this documentation, it should be something like
var myCallableStatement = myconnection.prepareCall("{call myprocedure(?)}");Thank you
最满意答案
我设法让它运行,这是有效的语法:
query = "call \"MyPackage.procedures::addUserC50\"(?, ?, ?)";谢谢你的帮助@shofmn
I managed to make it run, this is the syntax that worked:
query = "call \"MyPackage.procedures::addUserC50\"(?, ?, ?)";Thank you for your help @shofmn
更多推荐
发布评论