调用存储过程传递表类型参数

时间:2017-08-23 04:05:54

标签: java stored-procedures jdbc hana hana-sql-script

我在HANA数据库中创建了这个存储过程,它带有两个参数,一个是表类型,另一个是varchar

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

现在我想用Java调用这个程序,我写了这样的东西。

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();

有人可以告诉我如何在调用此存储过程时将对象作为参数传递给表实体吗?

1 个答案:

答案 0 :(得分:2)

无法在SAP HANA之外创建表类型输入参数。 对于客户端应用程序,仍然使用表类型参数的一种方法是使用与参数表具有相同结构的临时表。

然后,您的JAVA应用程序将首先填充临时表并在第二步中调用该过程

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