Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9069385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:24:54+00:00 2026-06-16T17:24:54+00:00

I am new to OSX App development.I am trying to store 4 values (Date,

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:24:55+00:00Added an answer on June 16, 2026 at 5:24 pm

    First check the date already exist or not

    if (sqlite3_open(dbpath, &quizDB) == SQLITE_OK)
    {
            sqlite3_stmt *statement;
    
            // ================Read date with current date value table===================
            NSString *readDate = [NSString stringWithFormat: @"SELECT * FROM TABLEOBJ WHERE DATE = %@",sampleDay.date];
    
            const char *readDate_stmt = [readDate UTF8String];
            if (sqlite3_prepare_v2(quizDB, readDate_stmt, -1, &statement, NULL) == SQLITE_OK)
            {
                NSString *str;
    
                if (sqlite3_step(statement) == SQLITE_ROW) 
                {
                    str = [NSString stringWithFormat:@"INSERT INTO TABLEOBJ (DATE,NIDHIN,PAI,RUBEN ) VALUES ('%@',%li,%li,%li)", sampleDay.date, sampleDay.value1, sampleDay.value2, sampleDay.value3];
                }
                else
                {
                     str = [NSString stringWithFormat:@"UPDATE TABLEOBJ SET NIDHIN = %li, PAI = %li, RUBEN = %li where DATE = %@", sampleDay.value1, sampleDay.value2, sampleDay.value3,sampleDay.date]; 
                }
    
                // Do the execution steps
                sqlite3_finalize(statement);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new at Mac OSx development. The app that I am creating requires
I am new to OSX development and i need your help please. I am
I am new to OSX App development and finds things a little different from
I'm making a new OSX app and I'm trying to copy the flow that
I am very much new to OSX development. Consider this as my first app.
I'm currently testing a new version of an app of mine on OSX 10.5
I am fairly new to OSX development, so this may be easy but google
I am new to OSX user space development. I've read documentation and googled before
I'm trying to define a new URL handler under OSX that will point at
I am very new to iPhone app development. I am developing one example application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.