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 8226803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:54:10+00:00 2026-06-07T15:54:10+00:00

This is the method I’m trying to use: NSString *orario = [NSString new]; int

  • 0

This is the method I’m trying to use:

NSString *orario = [NSString new];
int idmed = 0;
fileMgr = [NSFileManager defaultManager];
sqlite3_stmt *stmt=nil;
sqlite3_stmt *stmt1=nil;
sqlite3_stmt *stmt2=nil;
sqlite3 *dbase;
NSString *database = [self.GetDocumentDirectory stringByAppendingPathComponent:@"med.sqlite"];
sqlite3_open([database UTF8String], &dbase);
const char *sql = "delete from orari where date(orario) <= date('now','-2 day','localtime')";
sqlite3_prepare_v2(dbase, sql, -1, &stmt, NULL);
sqlite3_step(stmt);
const char *sql1 = "select orario,idmedicina from orari where date(orario)=date('now','localtime') and forever = 1";
const char *sql2 = "insert into orari (orario,idmedicina,presa,forever) values (datetime('?','+1 day'),?,0,1)";
sqlite3_prepare_v2(dbase, sql1, -1, &stmt1, NULL);

while(sqlite3_step(stmt1) == SQLITE_ROW) {
    orario = [NSString stringWithUTF8String:(char *)sqlite3_column_text(stmt1, 0)];
    idmed = [[NSNumber numberWithInt:(int)sqlite3_column_int(stmt1, 1)] intValue];
    sqlite3_prepare_v2(dbase, sql2, -1, &stmt2, NULL);
    sqlite3_bind_text(stmt2, 1, [orario UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_int(stmt2, 2, idmed);
    sqlite3_step(stmt2);
}
sqlite3_close(dbase);

The 3 queries seem to me to be correct, but the last one does not insert any row.
The second one, gets one row, so the last one should work (and it does if I use it directly).
What do you think is wrong?

  • 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-06-07T15:54:12+00:00Added an answer on June 7, 2026 at 3:54 pm

    In your code here:

    const char *sql2 = "insert into orari (orario,idmedicina,presa,forever) values (datetime('?','+1 day'),?,0,1)";
    

    you put quotes around your ? (Where is says values (datetime('?' change it to values (datetime(?).
    The resulting code should look like this:

    const char *sql2 = "insert into orari (orario,idmedicina,presa,forever) values (datetime(?,'+1 day'),?,0,1)";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use this method to access my mysql database from Xcode: NSString *URL =
This method is generated by Xcode 3.2 using Accessor defs to clipboard - (void)setBodyMass:(int)newBodyMass
This method shows a new window in my application: public void ShowNewCustomerView() { if
This method does the following : it gets the int startAge from the Database.
Consider this method: public IEnumerable<T> GetList(int Count) { foreach (var X in Y) {
This is the webservice method i have LoadImageFromDB(int ID, ref Stream streamReturnVal) I have
This is the method I use to find the key of a requested item
Some method call this method which has this code: Form frm = new Form();
This method in Android, MotionEvent.getPointerCount () , has only been starting to use since
This is my method which talks to the database with JPA: public Collection<ModuleConnection> getConnections(int

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.