Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

XSJS: Insert Into does not create a record in table

$
0
0

Hey guys its me again,

 

i created a xsjs function which should insert a singel record to a given table, my cuurent code looks like below.

 

function insertRecordsIntoTable(schemas,tables,fields,values){    // Set action    var statement = "INSERT INTO ";     // specify target table    var target = "\""+schemas[0]+"\".\""+tables[0]+"\" ";    statement = statement.concat(target);    var index;    // Build column part    var columns = "(";    for(index=0;index<fields.length-1;index++){        columns = columns.concat(fields[index]+",");    }     // Build value part    var vals = " VALUES (";    for(index=0;index<values.length-1;index++){        vals = vals.concat("?,");    }    // Concat tails to builded Strings    vals = vals.concat("?)");    columns = columns.concat(fields[fields.length-1]+")");  // Concat to final statement    statement = statement.concat(columns);    statement = statement.concat(vals);    try{        $.trace.debug(statement);        var conn = $.db.getConnection();        var pstmt =conn.prepareStatement(statement);       // Replace placeholder with final values concerning sql injection        for(index=0;index<values.length;index++){            pstmt.setString(index+1,values[index]);        }        pstmt.execute();        return true;    }catch(e){        return e;    }
}

 

When i run it, everything seems fine but if i take a look at the target table no data record is created and i have no clue why this happens.

Does anyone have a suggestions or had the same problem?

 

Edit: I tried following statements:

 

INSERT INTO SCHEMA.TABLE (COL1,COL2,COL3) VALUES (?,?,?)

INSERT INTO SCHEMA.TABLE (COL1,COL2,COL3) VALUES ('?','?','?')

and of course raw values.

 

Thank you for your answers in advance :-)

 

Best Regards,

 

Lukas

 

Message was edited by: Lukas Kaeser


Viewing all articles
Browse latest Browse all 6412

Trending Articles



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