-
Notifications
You must be signed in to change notification settings - Fork 15
Insert
Ujjwal Gupta edited this page Jul 27, 2020
·
5 revisions
insert into TABLE_NAME ({column1:value1,column2:value2,...});
e.g -
INSERT INTO CUSTOMERS ("{ID:1,NAME:'Ramesh',AGE:32,ADDRESS:'Ahmedabad',SALARY:2000}");
Get Inserted Record Value (Helpful when using autoIncrement & need inserted autoIncrement column value)
add option return
in last of query
e.g -
INSERT INTO CUSTOMERS ("{ID:1,NAME:'Ramesh',AGE:32,ADDRESS:'Ahmedabad',SALARY:2000} return");
var data = [{
"ProductID": 1,
"ProductName": "Chais",
"SupplierID": 1,
"CategoryID": 1,
"Unit": "10 boxes x 20 bags",
"Price": 18
},
{
"ProductID": 2,
"ProductName": "Chang",
"SupplierID": 1,
"CategoryID": 1,
"Unit": "24 - 12 oz bottles",
"Price": 19
}
]
var qry = new SqlWeb.Query("insert into Products Values='@values'");
qry.map("@values", data);
await con.runSql(qry)
e.g -
INSERT INTO CUSTOMERS ("{ID:1,NAME:'Ramesh',AGE:32,ADDRESS:'Ahmedabad',SALARY:2000} upsert");