cancel
Showing results for 
Search instead for 
Did you mean: 

XS Engine SQL Update doesn't write to DB

Former Member
0 Kudos

This is the important code:

conn = $.db.getConnection();

var query = "UPDATE \"LASVEGAS\".\"lasvegas.data::listener\" SET \"isActive\" = '0'  WHERE \"ID\" = ?";

var pstmt = conn.prepareStatement(query);

pstmt.setString(1, listener_id);

var updateCount = pstmt.executeUpdate();

$.response.contentType = "text/html";

$.response.setBody("Success!<br />"+updateCount+" rows affected.");

$.response.status = $.net.http.OK;

I run it on XS engine and get "Success! 1 rows affected." as a result. But when I look to the DB, nothing changed. If I run the exact same SQL query in the SQL console in HANA Studio it works. I'm always using the same user....

Accepted Solutions (1)

Accepted Solutions (1)

former_member182114
Active Contributor
0 Kudos

Hi Tobias,

If your Autocommit is not set to true, you must trigger it manually.

More details on documentation:

http://help.sap.com/hana/SAP_HANA_XS_JavaScript_Reference_en/$.db.Connection.html

Regards, Fernando Da Rós

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks for your replies, adding the line "conn.commit();" after executeUpdate worked for me.

pfefferf
Active Contributor
0 Kudos

Hi, have you tried to do a commit after the executeUpdate Statement ($.conn.commit();)? Regards.