title: Problems with SQLite3 Insert statement, xcode 4.2 developing for IOS 5
body: <p>It's my first time trying to develop an SQLite database for IOS, or any IOS app for that matter. I'm trying to follow a tutorial I found online and adapt it for my own use. The database was created without any issues but my Insert statement never seems to return my error message. 
  Nothing appears in the console as nothing drastic actually goes wrong with the program. If you need any more information I'll try my best to find it and update the question with it.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>// Method to store a GPS location
  -(void)insertGPS:(GPS*)GPS
  {
  // Create insert statement for the person
  NSString *insertStatement = [NSString stringWithFormat:@"INSERT INTO GPSJob (jobNo, sourceMonitor, positionNumber, latitude, longitude) VALUES (\"%@\", \"%@\", \"%@\",\"%@\",\"%@\")", GPS.jobNumber, GPS.sourceMonitor, GPS.positionNumber, GPS.latitude, GPS.longitude ];
  // Define an error
  char *error;
  // Attempt to execute the insert statement
  if ( sqlite3_exec(databaseHandle, [insertStatement UTF8String], NULL, NULL, &amp;error) == SQLITE_OK)
  {
      NSLog(@"GPS inserted into database with values: %@, %@, %@, %@, %@.", GPS.jobNumber, GPS.sourceMonitor, GPS.positionNumber, GPS.latitude, GPS.longitude);
  }
  // If the insert statement is not okay
  else {
      NSLog(@"Error: %s", sqlite3_errmsg(databaseHandle));
  }
  }
  </code></pre>
  
  <p>Here is the tutorial I'm following: <a href="http://www.apptite.be/tutorial_ios_sqlite.php" rel="nofollow">http://www.apptite.be/tutorial_ios_sqlite.php</a></p>
  
  <p>The updated error message said this : </p>
  
  <pre><code>2015-08-12 15:28:25.299 NoiseApp[7602:207] Error: out of memory
  </code></pre>
  
  <p>-----------------------------------Solution----------------------------------</p>
  
  <p>For anyone who wants the solution to this problem I simply amended the function to read as follows :</p>
  
  <pre><code>// Method to store a GPS location
  -(void)insertGPS:(GPS*)GPS
     {    
  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];
  NSString *databasePath = [documentsDirectory stringByAppendingPathComponent:@"GPS.db"];
  if(sqlite3_open([databasePath UTF8String], &amp;databaseHandle) ==SQLITE_OK){
  // Create insert statement for the person
  NSString *insertStatement = [NSString stringWithFormat:@"INSERT INTO GPSJob (jobNo, sourceMonitor, positionNumber, latitude, longitude) VALUES (\"%@\", \"%@\", \"%@\",\"%@\",\"%@\")", GPS.jobNumber, GPS.sourceMonitor, GPS.positionNumber, GPS.latitude, GPS.longitude ];
  // Define an error
  char *error;
  // Attempt to execute the insert statement
  if ( sqlite3_exec(databaseHandle, [insertStatement UTF8String], NULL, NULL, &amp;error) == SQLITE_OK)
  {
      NSLog(@"GPS inserted into database with values: %@, %@, %@, %@, %@.", GPS.jobNumber, GPS.sourceMonitor, GPS.positionNumber, GPS.latitude, GPS.longitude);
  }
  // If the insert statement is not okay
  else  {
      NSLog(@"Error: %s", sqlite3_errmsg(databaseHandle));
  }
  }
  }
  </code></pre>