Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3184

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

$
0
0

The below Java script is having an issue when I try to insert it through the variable but the hard coding of the value has no issues.

 

Code that needs to be fixed:   Passing a variable into the values of the insert is not working

 

var conn = $.db.getConnection();

var i = 1;

for (i = 1; i < 100; i++)

{

var pstmt = conn.prepareStatement("INSERT INTO \"SYSTEM\".\"LOOP\" VALUES (i)");

var rs = pstmt.execute();

}

conn.commit();

 

Code that works:  Passing a hard coded into the values has no issues

 

var conn = $.db.getConnection();

var i = 1;

for (i = 1; i < 100; i++)

{

var pstmt = conn.prepareStatement("INSERT INTO \"SYSTEM\".\"LOOP\" VALUES (100)");

var rs = pstmt.execute();

}

conn.commit();

 

Can someone let me know what I am doing wrong in the code that needs to be fixed? I don't want to hard code the values but pass the dynamic variable as a value for insert.

 

Thank you,

 

Sundeep


Viewing all articles
Browse latest Browse all 3184

Trending Articles



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