cancel
Showing results for 
Search instead for 
Did you mean: 

Error 328 when calling a HANA function via JDBC

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

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\" (?,?,?) "
vijay_kumar49
Active Contributor
0 Kudos

Does it work if you change like this?

String storeFunc = "{CALL myfunc(?,?,?)}";

http://itquestionz.com/questions/2249903/call-a-stored-procedure-in-hana

Call a Stored Procedure in HANA - iswwwup.com

Former Member
0 Kudos

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)

vijay_kumar49
Active Contributor
0 Kudos

com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [328]: invalid name of function or procedure: MYFUNC: line 1 col 8 (at pos 7)



MYFUNC:- this function or procedure name is valiable in DB?

Former Member
0 Kudos

Sure, the function name is valid and exists in the HANA catalog.

vijay_kumar49
Active Contributor
0 Kudos

as per the error log  its showing the MYFUNC is not valied

Former Member
0 Kudos

That's the reason why I'm writing this topic 🙂

The prepareCall works well with a procedure.

For a function, you'll get error 328.

vijay_kumar49
Active Contributor
0 Kudos

Please reffer this thread Link