Surily
Surily

Reputation: 121

string concatenation issue during insert statement

I have a method that constructs an insert query but crashes due to string being malformed. What is that i am missing?

saveWorkDocket : function(onSuccessCallback, onErrorCallback, options) {            
    var db = Ti.Database.open('xyz');      
    db.execute("INSERT INTO tbl_temp  (tableName, data, id, dateCreated) VALUES ('" + options.tableName + "','" + options.data + "','" + options.workdocketID + "','" + options.dateCreated +'");
    db.close();
}

Upvotes: 0

Views: 36

Answers (1)

Gouda Elalfy
Gouda Elalfy

Reputation: 7023

You missing to close double " in the end of the query and close the function brackets, try this:

var db = Ti.Database.open('xyz');      
db.execute("INSERT INTO tbl_temp  (tableName, data, id, dateCreated)   VALUES ('" + options.tableName + "','" + options.data + "','" + options.workdocketID + "','" + options.dateCreated +'")");

Upvotes: 2

Related Questions