I am new to OSX App development.I am trying to store 4 values (Date, value1, value2, value3) in sqlite databse. I need to update the last 3 fields of a record if a new record is entered with the existing date. How can i do it. My code to insert into database is given below
- (void) addToDatabase:(Day *)sampleDay
{
databasePath = [Database_Access createDirectory];
const char *dbpath = [databasePath UTF8String];
if (sqlite3_open(dbpath, &database) == SQLITE_OK)
{
char *errMsg;
NSString *str= [NSString stringWithFormat:@"INSERT INTO TABLEOBJ (DATE,NIDHIN,PAI,RUBEN ) VALUES ('%@',%li,%li,%li)", sampleDay.date, sampleDay.value1, sampleDay.value2, sampleDay.value3];
const char *sql_stmt = [str UTF8String];
if (sqlite3_exec(database, sql_stmt, NULL, NULL, &errMsg) != SQLITE_OK)
{
}
sqlite3_close(database);
}
else
{
}
}
What all are to be included in order to meet this requirement?