1

I'm implementing sqlite in my swift project and with update query i am updating some value from table but i am getting syntax error i am not sure why i am getting error.

UPDATE Code

 let updateStatementString = "UPDATE CreateInspDrawingDetail SET edit_file_name = \(self.imgbase64!) WHERE property_id = \(property_ID!) AND properties_drawings_id = \(self.drawingID!)"
 var updateStatement: OpaquePointer? = nil
 if sqlite3_prepare_v2(db, updateStatementString, -1, &updateStatement, nil) == SQLITE_OK {
        if sqlite3_step(updateStatement) == SQLITE_DONE {
               print("Successfully updated row.")
        } else {
               print("Could not update row.")
        }
      } else {
            print("UPDATE statement could not be prepared")
      }
      sqlite3_finalize(updateStatement)

i am getting syntax error like below

near "/": syntax error UPDATE statement could not be prepared

i am do anything wrong in my query please tell me

steveSarsawa
  • 1,559
  • 2
  • 14
  • 31
Vishal Parmar
  • 615
  • 4
  • 31

1 Answers1

4

Try this

let updateStatementString = "UPDATE CreateInspDrawingDetail SET edit_file_name = '\(self.imgbase64!)' WHERE property_id = '\(property_ID!)' AND properties_drawings_id = '\(self.drawingID!)';"
 var updateStatement: OpaquePointer? = nil
 if sqlite3_prepare_v2(db, updateStatementString, -1, &updateStatement, nil) == SQLITE_OK {
        if sqlite3_step(updateStatement) == SQLITE_DONE {
               print("Successfully updated row.")
        } else {
               print("Could not update row.")
        }
      } else {
            print("UPDATE statement could not be prepared")
      }
      sqlite3_finalize(updateStatement)
steveSarsawa
  • 1,559
  • 2
  • 14
  • 31