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

  • Home
  • SEARCH
  • 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 108963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:59:41+00:00 2026-05-11T01:59:41+00:00

I am using SQLite3 for iPhone development and I’m attempting to wrap a few

  • 0

I am using SQLite3 for iPhone development and I’m attempting to wrap a few insert statements into a transaction. Currently I have the below code which is working properly however after reading another question on SO I realized it would be better to have these in one transaction rather than one each. I couldn’t find the C API call to begin and commit a transaction. Some of the code is in Objective-C but I don’t think that’s really relevent to the question.

- (void)saveAnimals {     //Insert all the animals into the zoo database     int i;      const char *sql = 'insert into Animal(Zoo_ID, Animal_Num, Animal_Text) Values(?, ?, ?)';     for (i = 0; i < ([[self animalArray] count] - 1); i++) {          if(addStmt == nil) {             if(sqlite3_prepare_v2(database, sql, -1, &addStmt, NULL) != SQLITE_OK)                 NSAssert1(0, @'Error while creating add statement. '%s'', sqlite3_errmsg(database));         }         int animalNum = [[[self animalArray] objectAtIndex:i] animal_Number];         NSString *animalText = [[NSString alloc] initWithString:[[[self animalArray] objectAtIndex:i] animal_Text]];         sqlite3_bind_int(addStmt, 1, zoo_ID);            sqlite3_bind_int(addStmt, 2, animalNum);             sqlite3_bind_text(addStmt, 3, [animalText UTF8String], -1, SQLITE_TRANSIENT);         [animalText release];         if(SQLITE_DONE != sqlite3_step(addStmt)) {             NSAssert1(0, @'Error while inserting data. '%s'', sqlite3_errmsg(database));         }          //Reset the add statement.         sqlite3_reset(addStmt);          } } 

What I think needs to be done would be taking the sqlite3_prepare_v2 command out of the for loop, start the transaction, go through the for loop, commit the transaction. However, I’m not sure what the calls for ‘start the transaction’ and ‘commit the transaction’ are. And would I still use sqlite3_step? Thanks for your help.

  • 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. 2026-05-11T01:59:41+00:00Added an answer on May 11, 2026 at 1:59 am

    Start a transaction with: sqlite3_exec(db, 'BEGIN', 0, 0, 0);

    Commit a transaction with: sqlite3_exec(db, 'COMMIT', 0, 0, 0);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 208k
  • Answers 208k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I was desperatly searching the web for an answer and… May 12, 2026 at 9:37 pm
  • Editorial Team
    Editorial Team added an answer Using ASPX style isn't possible. You can use XsltArgumentList to… May 12, 2026 at 9:37 pm
  • Editorial Team
    Editorial Team added an answer would this help? Should be very easy to port to… May 12, 2026 at 9:37 pm

Related Questions

I am using SQLite3 for iPhone development and I'm attempting to wrap a few
I am a beginner to iPhone App development. Please help me out. In my
I have already created a table to the database. Table is something like following
Coming from a non-SQL background, I've been having a hard time absorbing SQLite3 for
I've got an iPhone app I'm developing and when the app launches I open

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.