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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:17:54+00:00 2026-06-12T00:17:54+00:00

I try to do an update in a table using sql wrapper (FMDB). Insert

  • 0

I try to do an update in a table using sql wrapper (FMDB). Insert method is oky and when I try to update data in the table problems occur.

- (void)saveUserMoneyValidation:(UserDebtInfo *)entities
{
    NSLog(@"entities.client_index = %d", entities.client_index);

    [self deleteUserMoneyValidation:entities.client_index];

    FMDatabase *newdb = [FMDatabase databaseWithPath:databasePathStore];

    [newdb setLogsErrors:TRUE];
    [newdb setTraceExecution:FALSE];

    if (![newdb open])
    { 
        NSLog(@"!!! Could not open db."); 
        return; 
    }
    else 
    { 
        NSLog(@"DB Open successfuly."); 
    }

    [newdb beginTransaction];
    NSLog(@"entities = %@",entities);

    [newdb executeUpdate:@"INSERT INTO MoneyValidation (client_index, client_name, sum, duration, monthly_payment, payment_type, debt_type, debt_code, categoryType) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
    [NSNumber numberWithInt:entities.client_index],
     entities.client_name,
     entities.sum,
     entities.duration,
     entities.monthly_payment,
     entities.payment_type,
     entities.debt_type,
     [NSNumber numberWithInt:entities.debt_code],
     entities.categoryType
     ];

    [newdb commit];
    [newdb close];
}

Update Method :

   -(void)updateUserMoneyValidation:(UserDebtInfo *)entities{
NSLog(@"entities.client_index = %d", entities.client_index);

FMDatabase *newdb = [FMDatabase databaseWithPath:databasePathStore];

[newdb setLogsErrors:TRUE];
[newdb setTraceExecution:FALSE];

if (![newdb open])
{ 
    NSLog(@"!!! Could not open db."); 
    return; 
}
else 
{ 
    NSLog(@"DB Open successfuly."); 
}

BOOL success = NO;

[newdb beginTransaction];
NSLog(@"entities = %@",entities);

success = [newdb executeUpdate:@"UPDATE MoneyValidation SET client_name = ?, sum = ?, duration = ?, monthly_payment = ?, payment_type = ?, debt_type = ?, debt_code = ?, categoryType = ?  WHERE client_index = %d;", entities.client_name, entities.sum, entities.duration, entities.duration, entities.monthly_payment, entities.payment_type, entities.debt_type, entities.debt_code, entities.categoryType, entities.client_index];

if (success)
{
    NSLog(@"OK");
    [db commit];
    [db close];
}
else 
{
    NSLog(@"FAIL");
}

NSLog(@"OBJ - %@", entities);}

The table structure :

CREATE TABLE MoneyValidation (ID INTEGER PRIMARY KEY, client_index INTEGER, client_name TEXT, sum TEXT, duration TEXT, monthly_payment TEXT, payment_type TEXT, debt_type TEXT, debt_code INTEGER, categoryType TEXT)
  • client_index is a unique code;

    Can someone help me with some advice about this problem?
    Thank you!

  • 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-12T00:17:55+00:00Added an answer on June 12, 2026 at 12:17 am

    I think the problem lies in your update statement. All values passed onto “executeUpdate” should be objects.

    In your update SQL statement, entities.debt_code and entities.client_index are being passed as INTEGERS, you need to pass them as NSNumber objects.

    Try the following:

    success = [newdb executeUpdate:@"UPDATE MoneyValidation 
               SET client_name = ?, sum = ?, 
               duration = ?, monthly_payment = ?, 
               payment_type = ?, debt_type = ?, 
               debt_code = ?, categoryType = ?  
               WHERE client_index = %d;", 
    
              entities.client_name, entities.sum, 
              entities.duration, entities.duration, 
              entities.monthly_payment, entities.payment_type, 
              entities.debt_type, 
              [NSNumber numberWithInt:entities.debt_code],  // Convert int to object type
              entities.categoryType, 
              [NSNumber numberWithInt:entities.client_index] // Convert int to object type
              ];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to update a table using another table. I get the error number
I try to update database table and this is my code: public void updatefiletable(String
I have a DAO class which I'm using to try select/update/insert with hibernate and
I'm getting the following exception when I try to update a table using Linq
Possible Duplicate: C# Update Table using SqlCommand.Parameters I'm trying to update an SQL Server
I am using mysql and hibernate to insert and update rows in a table.
i try to update simple data to table name order but i still get
Basically try to do the same as: UPDATE table SET column3 = column1 +
I try to update a column in an table with the following query. In
I try to realize a link (in fact many links) that update a table

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.