Skip to Content
avatar image
Former Member

Error while inserting record from XSJS

Hi,

I have created table using the following definition.

When I insert record from SQL console it is working perfectly.

But when I do the same from XSJS it throws the error as

found the following errors:

===========================

InternalError: dberror(PreparedStatement.execute): 598 - failed to execute the external statement: failed to execute at remote: peer=127.0.0.1:30103: unhandled exception (line 14 position 1 in /tryouts/monissha/projects/poc/services/demo.xsjs)

The xsjs code is as follows,

var conn;

var pstmt;

var rs;

conn = $.db.getConnection();

pstmt = conn.prepareStatement('INSERT INTO  "SAPHANA_ROI"."Scenario" VALUES ("SAPHANA_ROI"."ScenarioId".NEXTVAL, ?, ?, ?)');

pstmt.setString(1, $.session.getUsername());

pstmt.setString(2, '');

pstmt.setString(3, '');

pstmt.execute();

conn.commit();

$.response.setBody(0);

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

pstmt.close();

conn.close();

Help me out in resolving this issue.

Thanks & Regards,

Monissha

1.png (24.7 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jan 06, 2015 at 06:14 AM

    Hi Monissha,

    First of all, surround these statement with a try catch block and get the exact exception message.

    Instead of pstmt.execute(), try pstmt.executeUpdate();

    Sree

    Add comment
    10|10000 characters needed characters exceeded