Hey, what do I want to do is update a table if the field exsits or enter the new value given by the user. / P>
Select everything that exists in the table and check that the names entered by the user are present or update it or otherwise enter it
However The problem occurs when there is no data in the table, the query fails and no data is entered in the table.
NSString * query = @ "select * from PPM"; Sqlite_stmt * statement; If (sqlite_prepare_v2 (database, [query UTF8string], - 1, & amp; statement, zero) == SQLITE_OK) {while (sqlite3_step (statement) == SQLITE_ROW) // Select data from the table // if entered Value is same as the user updated the table / / other entries in the table}
How to INSERT or Replace ? If you already exist, you can use it with the UNIQUE constraints in your database structure to change it, and enter it if it is not already present.
Shell> Enter ".help" for Sqlite3 SQLite version 3.6.23 instructions; ";" SQLite & gt; Create a table user (unique, name); SQLite & gt; Enter or change user values ("foo", 123); SQLite & gt; Choose from user; Foo | 123 sqlite & gt; Add or change user values ("foo", 321); SQLite & gt; Choose from user; Foo | 321
Comments
Post a Comment