0

I am having problems writing statements, especially when updating.

  • I want to update a column with a parameter, but I don't know the special characters to use like @ or %d.

I tried to do:

const char *sqlStatement = [[NSString stringWithFormat:
  @"update lugar set frecuencia ='d%'aumentador Where idLugar = '%d'",
  idLugarParametro] cStringUsingEncoding:NSUTF8StringEncoding];

But I get a problem with: frecuencia ='d%'aumentador

  • How can I find a guide or tutorial for using this special characters for creation statements? (Using Objective C specifically.)
1

1 Answer 1

2

Here's An Introduction To The SQLite C/C++ Interface.

Here's the Apple documentation for NSString stringWithFormat, and string format specifiers.

I note that it seems you typed d%, but probably meant %d for the format specifier (you might need an extra space in there too), and that you've only supplied one arg (idLugarParametro), but your format string has two specifiers:

------------------------------1v------------------------------2v
update lugar set frecuencia ='%d' aumentador Where idLugar = '%d'

so you need to supply two values - the new frecuencia value is not there.

Lastly, suggest that you look in to the use of prepared statements once you've got the hang of the basics - see the SQLite docs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.