on 01-06-2015 5:21 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sree,
I have replaced the sequence with the whole number still i got the same error. But when I changed the prepare statement like the following it worked.
pstmt = conn.prepareStatement('INSERT INTO "SAPHANA_ROI"."Scenario" VALUES ("SAPHANA_ROI"."ScenarioId".NEXTVAL, \'\', \'\', \'\')');
i.e., I removed the setstring statements instead gave the null values directly there.
Can you please explain?
But I need to use the setstring method in my application since I would be getting the values from the user.
Thanks,
Monissha
Monnissha,
Check the blog by Thomas.
Sree
You missed the point of what I was saying. You are already using the setters/getters - as all pre-SPS09 DB XSJS code would be. You don't need a sample for that. I was saying that in SPS09 you don't need the setters/getters at all with the new $.hdb database interface. For examples of that refer to the blog link already provided by Sreehari in the comments or have a look at the online help.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.