title: Make a Loop Array or Bulk to Insert Dictionary with Multiple Values from a parsed Json string into a SQLite database with FMDB iOS. Objective C
body: <p>I have a Parsed Json string in which I would like to loop the values and insert them into my FMDB Sqlite database. I can only put one record at a time in the database. i want to put all my records in the sqlite database.</p>
  
  <p>I know I have to make up some sort of loop for this.</p>
  
  <p>I want to take the parsed json which has multiple values below and insert it into my column named unitofMeasure and Name.</p>
  
  <p>So I want to create a loop to insert multiple id's and multiple names into the unitOfMeasureID column and Name column in my database. </p>
  
  <p>Currently I can only insert i record at a time.</p>
  
  <pre><code>UnitOfMeasureID To Use: 1
  Name: kph
  UnitOfMeasureID To Use: 2
  Name: kpm
  UnitOfMeasureID To Use: 3
  Name: kpm
  
    for (defineJsonDataLookUp in self.jsonLookup)
  {
      NSNumber* UnitOfMeasureID = [defineJsonDataLookUp objectForKey:@"unitOfMeasureID"];
      NSLog(@"UnitOfMeasureID To Use: %@", UnitOfMeasureID);
  
      NSNumber* Factor = [defineJsonDataLookUp objectForKey:@"Factor"];
      NSLog(@"Factor To Use: %@", Factor);
  
      NSArray* Name = [defineJsonDataLookUp objectForKey:@"Name"]; //for actual json response
      NSLog(@"Name: %@", Name); //3
  
      NSNumber* ParentID = [defineJsonDataLookUp objectForKey:@"ParentID"];
      NSLog(@"ParentID: %@", ParentID);
  }
  
  if ([strResult isEqualToString:@"[]"])
  {
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection!" message:@" Please connect to the Internet" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
      [alert show];
      return;
  }
  
  else
  {
  
      for (defineJsonDataLookUp in self.jsonLookup)
      {
          NSNumber* UnitOfMeasureID = [defineJsonDataLookUp objectForKey:@"unitOfMeasureID"];
          NSLog(@"UnitOfMeasureID To Use: %@", UnitOfMeasureID);
  
          NSNumber* Factor = [defineJsonDataLookUp objectForKey:@"Factor"];
          NSLog(@"Factor To Use: %@", Factor);
  
          NSArray* Name = [defineJsonDataLookUp objectForKey:@"Name"]; //for actual json response
          NSLog(@"Name: %@", Name); //3
  
          NSNumber* ParentID = [defineJsonDataLookUp objectForKey:@"ParentID"];
          NSLog(@"ParentID: %@", ParentID);
  
          FMDatabase *db = [FMDatabase databaseWithPath:[Utility getDatabasePath]];
  
          [db open];
  
          [db executeUpdate:[NSString stringWithFormat:@"delete from unitofmeasure"]];
  
              [db executeUpdate:@"INSERT INTO unitofmeasure   (unitOfMeasureID,Factor,Name,ParentID) VALUES (?,?,?,?)",UnitOfMeasureID,Factor,Name,ParentID];
  //                [db executeUpdate:@"INSERT INTO unitofmeasure (unitOfMeasureID,Name) VALUES (?,?);",
  //             [self.defineJsonDataLookUp objectForKey:@"unitOfMeasureID"],[self.defineJsonDataLookUp objectForKey:@"Name"], nil];
          FMResultSet *results = [db executeQuery:@"select * from unitofmeasure"];
          while([results next]) {
              NSString *Name = [results stringForColumn:@"Name"];
              NSInteger ParentID  = [results intForColumn:@"ParentID"];
              NSLog(@"UdadfdadfddfFuckingser: %@ - %d",Name, ParentID);
          }
          [db close];
  
      }
  
      HUD.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]];
      HUD.mode = MBProgressHUDModeCustomView;
      [HUD hide:YES afterDelay:0];
  
  }
  
  
  }
  </code></pre>
  
  <p>My SQlite Database looks like this and I want to insert all the records from my dictionary UnitOfMeasureID: 1, Name:kph, UnitOfMeasureID: 2, Name: kpm, UnitOfMeasureID: 3, Name: kpm</p>
  
  <p><img src="https://i.stack.imgur.com/7ZmGl.png" alt="enter image description here">
  Regards</p>