Open parvbhaskar opened 8 years ago
The Swift sample in the README
includes an example:
let documents = try! NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false)
let fileURL = documents.URLByAppendingPathComponent("test.sqlite")
let database = FMDatabase(path: fileURL.path)
if !database.open() {
print("Unable to open database")
return
}
do {
try database.executeUpdate("create table test(x text, y text, z text)", values: nil)
try database.executeUpdate("insert into test (x, y, z) values (?, ?, ?)", values: ["a", "b", "c"])
try database.executeUpdate("insert into test (x, y, z) values (?, ?, ?)", values: ["e", "f", "g"])
let rs = try database.executeQuery("select x, y, z from test", values: nil)
while rs.next() {
let x = rs.stringForColumn("x")
let y = rs.stringForColumn("y")
let z = rs.stringForColumn("z")
print("x = \(x); y = \(y); z = \(z)")
}
} catch let error as NSError {
print("failed: \(error.localizedDescription)")
}
database.close()
You should show us what you tried and tell us what error you received.
Obviously, to do UPDATE
, it is
try database.executeUpdate("update test set x = ? where y = ?", values: ["foo", "bar"])
Please let me help to bind the query for below example.
"INSERT INTO (TABLE_TROUBLE_CODES) ((TROUBLE_CODE),(CODE_TITLE),(SERVICE_PROVIDER_TYPE),(TROUBLE_ID),(CODE_TYPE),(PLANT_CLASS_CODE)) VALUES (?,?,?,?,?,?), (obj.troubleCode!),(obj.codeTitle!), (obj.serviceProviderType!), (obj.troubleId!),(obj.codeType!),(obj.plantClassCode!)"
Hi i tried to use couples of the query format to execute the update query but every time it is giving error. Kindly share the code to update a table column with where syntex.