Skip to Content
author's profile photo Former Member
Former Member

XS Engine SQL Update doesn't write to DB

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....

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Sep 05, 2013 at 04:21 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 05, 2013 at 04:05 PM

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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 06, 2013 at 08:35 AM

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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.