Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3316

Re: Issue with passing variable to INSERT statement in the HANA xsjs file

$
0
0

Well, of course you need to adapt it to your code reality. Either way, this is what it would look like:

 

[...]
var pstmt = conn.prepareStatement("INSERT INTO \"SYSTEM\".\"LOOPS\" VALUES (?)");
for (i = 1; i < 100; i++)
{
pstmt.setInteger(1,i);
pstmt.execute();
}
[...]

Using the hdb namespace you could have the following:

 

[...]
var strQuery = "INSERT INTO \"SYSTEM\".\"LOOPS\" VALUES (?)";
var conn = $.hdb.getConnection();
var i = 1;
for (i = 1; i < 100; i++) {
conn.executeUpdate(strQuery,i);
}
conn.commit();
[...]

Get familiar with the XS JS API here:  JSDoc: Index

 

One last thing: "LOOP" is a SQL reserved word in HANA. Not sure how (or if) you managed to use it as a table. Anyhow: don't use it.

 

BRs,

Lucas de Oliveira


Viewing all articles
Browse latest Browse all 3316

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>