on 07-28-2022 4:59 AM
Hi,
I am currently doing the development in HANA XSA Web ide, Reading the HANA procedure results and trying to update custom table with the results set in XSJS file. Could anyone please help me how to do that? Below is the code, How to parse the results into corresponding fields.
Facing errors while updating the data. Values in "results" are in JSON format.
Ex: id:1, name: Emp1, number:1111
id:2, name: Emp2, number:2222 etc.,
function create() {
var conn;
conn = $.hdb.getConnection();
var getProcedureData = conn.loadProcedure("xsajobsXSJS.db::EmpProcedure");
var results = getProcedureData();
conn.executeUpdate('INSERT INTO "xsajobsXSJS.db::tables.EmpData_2" (id, name, number) VALUES(?)',results);
conn.commit();
conn.close();
I think your coding should looks like this
conn.executeUpdate('INSERT INTO "xsajobsXSJS.db::tables.EmpData_2" (id, name, number) VALUES(?,?,?)',results.id,results.name,results.number);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You may need to first run "results = JSON.parse(results);" if results is not an object but a string.
Then, the coding should looks like this.
for (i = 0; i < results[0].length; ++i) {
conn.executeUpdate('INSERT INTO "xsajobsXSJS.db::tables.EmpData_2" (id, name, number) VALUES(?,?,?)',results[0][i].id,results[0][i].name,results[0][i].number);
}
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.