on 08-19-2015 3:27 PM
Dear all,
I'm trying to call a HANA function via JDBC and receive error 328 "invalid name of function or procedure" although the function exists in the catalog and is accessible.
Let's define an example:
create function myfunc ( in inpar1 varchar(30), in inpar2 varchar(30)) returns outpar1 varchar(30) as
begin outpar1 := concat(left(inpar1,1),inpar2); end
The following JDBC call leads to an exception with error 328.
String storeFunc = "{? = call myfunc(?,?)}";
try {
callableStatement = connection.prepareCall(storeFunc);
} catch (SQLException e) {
System.out.println(e.getMessage());
}
The almost identical coding works well when calling a HANA procedure.
Again an example:
create procedure myproc (in inpar1 varchar(30), in inpar2 varchar(30),out outpar1 varchar(30)) as
begin outpar1 := concat(left(inpar1,1),inpar2); end
The following JDBC call works as expected:
String storeProc = "{call myproc(?,?,?)}";
try {
callableStatement = connection.prepareCall(storeProc);
} catch (SQLException e) {
System.out.println(e.getMessage());
}
Does anybody have an idea to resolve this problem ?
Thanks in advance !
Best regards
Florian
Make Sure that You have added your current HANA Schema name before the procedure name with Quotation Mark
"SchemaName"."myproc" (?,?,?)
To send Quotation Mark in Procedure call use back slash (\)
" CALL \"SchemaName\".\"myproc\" (?,?,?) "
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does it work if you change like this?
String storeFunc = "{CALL myfunc(?,?,?)}";
http://itquestionz.com/questions/2249903/call-a-stored-procedure-in-hana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, but no, it does not work. The same error message pops up. It seems as if the database engine expects always a procedure but not a function.
The jdbc documentation at http://docs.oracle.com/javase/7/docs/api/java/sql/CallableStatement.html explains:
The JDBC API provides a stored procedure SQL escape syntax that allows stored procedures to be called in a standard way for all RDBMSs. This escape syntax has one form that includes a result parameter and one that does not. If used, the result parameter must be registered as an OUT parameter. The other parameters can be used for input, output or both. Parameters are referred to sequentially, by number, with the first parameter being 1.
Form 1: {?= call <procedure-name>[(<arg1>,<arg2>, ...)]}
Form 2: {call <procedure-name>[(<arg1>,<arg2>, ...)]}
com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [328]: invalid name of function or procedure: MYFUNC: line 1 col 8 (at pos 7)
at com.sap.db.jdbc.exceptions.SQLExceptionSapDB.createException(SQLExceptionSapDB.java:345)
at com.sap.db.jdbc.exceptions.SQLExceptionSapDB.generateDatabaseException(SQLExceptionSapDB.java:185)
at com.sap.db.jdbc.packet.ReplyPacket.buildExceptionChain(ReplyPacket.java:100)
at com.sap.db.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:1130)
at com.sap.db.jdbc.CallableStatementSapDB.sendCommand(CallableStatementSapDB.java:1964)
at com.sap.db.jdbc.StatementSapDB.sendSQL(StatementSapDB.java:978)
at com.sap.db.jdbc.CallableStatementSapDB.doParse(CallableStatementSapDB.java:256)
at com.sap.db.jdbc.CallableStatementSapDB.constructor(CallableStatementSapDB.java:215)
at com.sap.db.jdbc.CallableStatementSapDB.<init>(CallableStatementSapDB.java:125)
at com.sap.db.jdbc.CallableStatementSapDBFinalize.<init>(CallableStatementSapDBFinalize.java:31)
at com.sap.db.jdbc.ConnectionSapDB.prepareCall(ConnectionSapDB.java:1328)
at com.sap.db.jdbc.trace.Connection.prepareCall(Connection.java:318)
at TestJdbc.main(TestJdbc.java:94)
Please reffer this thread Link
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.