尝试从服务端调用 SAP HANA 存储过程时出错

Error when trying to call SAP HANA stored procedure from service side

我正在尝试使用以下代码从我的服务端调用 SAP HANA hdb 过程。

var con = ConLib.getHDBConnection();
var uploadStmt = con.loadProcedure("_SYS_BIC" , "procname");
var result = uploadStmt("samplefield1",  "samplefield2", {"DATA":[{"id1":"id_1001","id2":"id_2001","year_col":"2018"}, {"id1":"id_1002","id2":"id_2002","year_col":"2019"}]})

程序将以下参数作为输入。

PROCEDURE procname (
IN field1 VARCHAR(100),
IN field2 VARCHAR(100)
IN in_table_data "schema_name"."hdbdd_file_name.table_type"
){}

in_table_data 在 hdbdd_file_name.hdbdd 文件中定义如下。

Type table_type {
id1 : String(100);
id2 : String(100);
year_col : String(4);}

当我从我的服务端调用程序时出现以下错误。

" Error occured in processRequest method $.hdb.Connection.executeProcedure: Parameter at  position 3 is not of type that can be processed "

能否请您建议在数据库端或服务端需要更改哪些内容以解决此问题。

提前致谢。

我的印象是你的调用语句中的数组定义不正确:

var result = uploadStmt("samplefield1", "samplefield2", {"DATA":[{"id1":"id_1001","id2":"id_2001","year_col":"2018"}, {"id1":"id_1002","id2":"id_2002","year_col":"2019"}]})

相反,像这样尝试:

var result = uploadStmt("samplefield1"
                      , "samplefield2"
            , [{id1: 'id_1001', id2: 'id_2001', year_col: '2018'}
             , {id1: 'id_1002', id2: 'id_2002', year_col: '2019'}]
                       )