The identifier sql3
is defined inside curly braces. Therefore it is purely local to those curly braces. Therefore when you get past that to the next part of your code, it no longer exists.
if ([typedepartie isEqual: @"ami"]) {
const char *sql3 = // sql3 is born here...;
} // and dies here
What you want is more like this:
char *sql3 = // default value;
if ([typedepartie isEqual: @"ami"]) {
sql3 = // other value;
}