So I'm currently compiling a simple SQL query like this:
const char *sqlQuery = "SELECT value FROM settings WHERE name=? LIMIT 1";
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlQuery, -1, &compiledStatement, nil) == SQLITE_OK)
{
sqlite3_bind_text(compiledStatement, 1, [name UTF8String], -1, SQLITE_TRANSIENT);
while(sqlite3_step(compiledStatement) == SQLITE_ROW)
{
NSString *theValue = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
// ...
}
}
However I would like to be able to change the table name I'm calling. I thought I could change the sqlQuery to:
const char *sqlQuery = "SELECT value FROM ? WHERE name=? LIMIT 1";
And then bind it before I bind the name value, however this doesn't work. I guess this is designed to only work for selection args...
Does anyone know if there is a way to insert the table name here or do I just have to do it in plain text?