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