0

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

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 "

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

先感谢您。

4

1 回答 1

0

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

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'}]
                       )
于 2020-05-06T23:19:31.773 回答