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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:23:30+00:00 2026-05-29T12:23:30+00:00

I am working on iphone application in which i have to insert multiples values

  • 0

I am working on iphone application in which i have to insert multiples values in table.
I am using the following code but getting the syntax error. Where is my syntax wrong?

INSERT INTO `ark1` (`A`, `B`, `C`) VALUES
('IKE', 'BEFÄLHAVARE OCH MILITÄRER', ' USA'),
('LEE', 'BEFÄLHAVARE OCH MILITÄRER', ' USA'),
('NEY', 'BEFÄLHAVARE OCH MILITÄRER', ' FRAN'),
('ALBA', 'BEFÄLHAVARE OCH MILITÄRER', ' SPAN'),
('FOCH', 'BEFÄLHAVARE OCH MILITÄRER', ' FRAN'),
('GIAP', 'BEFÄLHAVARE OCH MILITÄRER', ' VIET'),
('HAIG', 'BEFÄLHAVARE OCH MILITÄRER', ' USA')

Thanks

  • 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. Editorial Team
    Editorial Team
    2026-05-29T12:23:31+00:00Added an answer on May 29, 2026 at 12:23 pm

    Following code is use to insert data into the Database

    initialization of the database

    -(id)init{
        if(self=[super init]) {
            documentsDirectory_Statement;
            documentsDirectory=[documentsDirectory stringByAppendingPathComponent:@"yourApplication.sqlite"];
            self.dbPath=documentsDirectory;
            NSFileManager *fm=[NSFileManager defaultManager];
            if(![fm fileExistsAtPath:self.dbPath]) {
                NSString *localDB=[[NSBundle mainBundle] pathForResource:@"yourApplication" ofType:@"sqlite"];
                NSError *err;
                if(![fm copyItemAtPath:localDB toPath:self.dbPath error:&err]){
                    NSLog(@"Error in creating DB -> %@",err);
                }
            }
    
            if(sqlite3_open([self.dbPath UTF8String], &database) !=SQLITE_OK){
                NSLog(@"error while opening database.");
            } else {
                sqlite3_close(database);
            }
        }
        return self;
    }
    

    Numbers of Constants

    #define PUT_Value(_TO_,_FROM_) { \
    NSString *str=[dObj valueForKey:_FROM_]; \
    if(!str) str=@" "; \
    sqlite3_bind_text(compiledStmt,_TO_,[str UTF8String],-1,SQLITE_TRANSIENT); \
    }
    
    #define PUT_Blob(_TO_,_FROM_) { \
        sqlite3_bind_blob(compiledStmt,_TO_,[[dObj valueForKey:_FROM_] bytes],[[dObj valueForKey:_FROM_] length],NULL);\
    }
    
    #define PUT_Integer(_TO_,_FROM_) { \
        NSInteger numbr=[[dObj valueForKey:_FROM_] intValue]; \
        sqlite3_bind_int(compiledStmt,_TO_,numbr); \
    }
    
    
    #define PUT_Double(_TO_,_FROM_) { \
    CGFloat doubleX=[[dObj valueForKey:_FROM_] floatValue]; \
    sqlite3_bind_double(compiledStmt,_TO_,doubleX); \
    }
    
    
    #define PUT_Date(_TO_,_FROM_) { \
    sqlite3_bind_text(compiledStmt,_TO_, [[[dObj valueForKey:_FROM_] description] UTF8String], -1, SQLITE_TRANSIENT);\
    }
    
    
    #define GET_Value(_TO_,_FROM_) NSString *_TO_; { \
    const unsigned char *c=sqlite3_column_text(compiledStmt,_FROM_); \
    _TO_= c ? [NSString stringWithUTF8String:(char*)c] : @"" ; \
    }
    
    #define GET_Double(_TO_,_FROM_) double _TO_;{ \
    _TO_=sqlite3_column_double(compiledStmt,_FROM_); \
    }
    
    #define GET_Integer(_TO_,_FROM_) NSUInteger _TO_; { \
    _TO_ = sqlite3_column_int(compiledStmt,_FROM_); \
    }
    
    #define GET_Date(_TO_,_FROM_) { \
    _TO_=sqlite3_column_double(compiledStmt, _FROM_)];\
    }
    
    #define GET_Blob(_TO_,_FROM_) { \
    _TO_=sqlite3_column_blob(compiledStmt, _FROM_) length:sqlite3_column_bytes(compiledStmt, _FROM_)];\
    }
    

    Insert Funcation

    -(void)insertItem:(NSArray*)arItem{
    
        sqlite3_stmt *compiledStmt;
        if(sqlite3_open([self.dbPath UTF8String], &database) ==SQLITE_OK) {
    
    
            sqlite3_prepare_v2(database, "BEGIN TRANSACTION", -1, &compiledStmt, NULL);
            sqlite3_step(compiledStmt);
            sqlite3_finalize(compiledStmt);
    
            const char *sqlInsertQry="insert into alarm (id,years,months,days,hours,minutes,seconds,body) values(?,?,?,?,?,?,?,?)";
            if(sqlite3_prepare_v2(database, sqlInsertQry, -1, &compiledStmt, NULL) == SQLITE_OK ){
                for (NSDictionary *dObj in arItem) {
                    PUT_Integer(1,@"id");
                    PUT_Integer(2,@"years");
                    PUT_Integer(3,@"months");
                    PUT_Integer(4,@"days");
                    PUT_Integer(5,@"hours");
                    PUT_Integer(6,@"minutes");   
                    PUT_Integer(7,@"seconds");                
                    PUT_Value(8,@"body");                
    
    
                    NSUInteger err = sqlite3_step(compiledStmt);
                    if (err != SQLITE_DONE){
                        NSLog(@"error while binding %d %s",err, sqlite3_errmsg(database));
                    }
                    sqlite3_reset(compiledStmt);
                }
                sqlite3_finalize(compiledStmt);     
            } else {
                NSLog(@"Invalid Query");
            }
            sqlite3_prepare_v2(database, "END TRANSACTION", -1, &compiledStmt, NULL);
            sqlite3_step(compiledStmt);
            sqlite3_finalize(compiledStmt); 
            sqlite3_close(database);
        } else {
            NSLog(@"error while opening database.");
        }
    }
    

    Hope this code is helping to implement the database connectivity.

    @Samuel

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

Sidebar

Related Questions

I have developed a simple location aware iPhone application which is functionally working very
I am currently working in iPhone application in which I have used wikitude api.
I am working on an iPhone application in which I have HTML pages created
I have an iPhone application which I'm working on and so far i have
I am working on iphone application in which i have to return the keyboard
Currently i am working on a iPhone Application Which is displaying video. I have
I'm working on iphone application which needs to run offline at an exhibition. It
I'm working on an iPhone application which will use long-polling to send event notifications
I'm working on an iPhone application. I have an object of class Row that
I am working on iphone networking application.. I am using asihttp , a wrapper

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.