У меня есть этот код из учебника. Мне интересно, как изменить его так, чтобы он считывал не двойное число из базы данных, а просто строку.
if(detailStmt == nil) {
const char *sql = "Select price from Coffee Where CoffeeID = ?";
if(sqlite3_prepare_v2(database, sql, -1, &detailStmt, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating detail view statement. '%s'", sqlite3_errmsg(database));
}
sqlite3_bind_int(detailStmt, 1, coffeeID);
if(SQLITE_DONE != sqlite3_step(detailStmt)) {
//Get the price in a temporary variable.
NSDecimalNumber *priceDN = [[NSDecimalNumber alloc] initWithDouble:sqlite3_column_double(detailStmt, 0)];
//Assign the price. The price value will be copied, since the property is declared with "copy" attribute.
self.price = priceDN;
//Release the temporary variable. Since we created it using alloc, we have own it.
[priceDN release];
}
Я почти уверен, что строки, которые нужно изменить:
sqlite3_bind_int(detailStmt, 1, coffeeID);
NSDecimalNumber *priceDN = [[NSDecimalNumber alloc] initWithDouble:sqlite3_column_double(detailStmt, 0)];
Мне нужно будет использовать sqlite3_bind_text и sqlite3_column_text, но я не уверен, как правильно изменить параметры.
Заранее благодарю за помощь!