0

I have a table with values. I need to add or insert value in it. For example in table exists row("exml") with value: "123", and I want to add value "4567". After that it must be "1234567", if value does not exist it must be "4567", please help me..

LightNight
  • 1,616
  • 6
  • 30
  • 59
  • will you edit your question with more detail like table structure and example in format of tabular form. – CRDave Sep 19 '12 at 11:37
  • See the [SQLite documentation](http://www.sqlite.org/docs.html), particularly the links on SQL syntax and C/C++ API. – Hot Licks Sep 19 '12 at 11:43

2 Answers2

0

For This you have to first get existing data from table and then put a loop for Number of Records you got in database, Then you can do like this,

    for(int i=0;i<arrOldData.count;i++)
    {
        NSString *strNew;
        if([[arrOldData objectAtIndex:i] objectForKey:@"exml"])
        {
            strNew=[[[arrOldData objectAtIndex:i] objectForKey:@"exml"] stringByAppendingString:yourNewString];
        }
        else
        {
            strNew=yourNewString;
        }

        //your insert statement will be here with value(strNew)
    }

this is not complete code,this will just give you a brief idea of what you can do, I hope this will help you.

Anand
  • 1,129
  • 7
  • 29
0

Check the link it is described Creating Database, Creating Table ,

Open Database Retrieve data From the table

It will help you for inserting and retrieving values.

Creating an SQLite3 database file through Objective-C

Checkthis.

Community
  • 1
  • 1
Vineesh TP
  • 7,755
  • 12
  • 66
  • 130