title: Inserting Rows in Database Using Sqlite Iphone
body: <p>I have the following code n i have 4 records in data base but loop is running 2 times n getting only first row two times whats a problem in my code?</p>
  
  <pre><code>- (void) getAllRowsFromTableName:(NSString *)tableName{
      NSString *qsql = [NSString stringWithFormat:@"SELECT * FROM '%@'",tableName];
     
      NSLog(@"query is :%@",qsql);
      sqlite3_stmt *statement;
      if (sqlite3_prepare_v2(db,[qsql UTF8String] , -1, &amp;statement,nil) == SQLITE_OK) {
          while (sqlite3_step(statement) == SQLITE_ROW) {
              NSLog(@"loop");
              int catId = sqlite3_column_int(statement, 1);
               NSLog(@"***CatId is :%d",catId);
  
                  sqlite3_finalize(statement);
          }
          sqlite3_finalize(statement);
      }
  </code></pre>