Skip to Content
avatar image
Former Member

how to delete rows from table using XSJS?

I have a table with 2 columns, USER and USER_EMAIL. This contains about 5 rows and I want to delete the rows using XSJS. Here is my attempt.

function cleanup(){

    var connection = $.db.getConnection();
    var query;
    try {
        query  = 'DELETE FROM \"SCHEMA\".\"TABLE\" WHERE \"USER\" = ' + "'" + rowValue + "'"; //here rowValue is a string variable

        var pstmt = connection.prepareStatement(query);
       var result = pstmt.executeUpdate();

     }catch (e) {
         $.response.status = $.net.http.INTERNAL_SERVER_ERROR;


I tested the query on HANA and it seems to work but when I run it through XSJS it doesn't work.

This is the query I ran on HANA


I ran both

var result = pstmt.executeUpdate(); and
var result = pstmt.executeQuery();

but neither one works, they run but the table is not updated. executeUpdate() returns "1". Not sure what that means. Also I'm using XS classic. If anyone has some idea of to get this working, please share.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jul 11, 2017 at 07:35 PM

    That method executeUpdate returns 1 means, that your statement updated 1 data record (please the the XS JS API reference for that).

    But I assume that the changed data is not commited, cause you have not executed method commit of the connection object (connection.commit()) and the autocommit mode is not enabled.


    Add comment
    10|10000 characters needed characters exceeded