Search code examples
javastored-proceduresjdbchanahana-sql-script

Call stored procedure passing table type argument


I've created this stored procedure in HANA database which is taking two parameters, one is a table type and other is varchar.

CREATE PROCEDURE UPDATE_GSTR(IN p_Input_Values "GSTR11".p_Input_Values , IN p_TRANS_ID VARCHAR(100))

Now I want to call this procedure in Java, I've written something like this.

Connection dbConnection = null;
CallableStatement callableStatement = null;

String storedProcedure = "{call UPDATE_GSTR(?,?)}";

dbConnection = jdbc.getDataSource().getConnection();
callableStatement = dbConnection.prepareCall(storedProcedure);

callableStatement.setString(1, "");
callableStatement.setString(2, "");

// execute store procedure
callableStatement.executeUpdate();

Can someone tell me how to pass the object as a table entity in the argument while calling this stored procedure?


Solution

  • The table typed input parameter cannot be created outside of SAP HANA. For client applications, one way to still use table typed parameters is to use temporary tables that have the same structure as the parameter table.

    Your JAVA application would then first fill the temporary table and call the procedure in a second step

    String storedProcedure = "{call UPDATE_GSTR("<temp_table_name>",?)}";