Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
pragmas are confusing.
  • Loading branch information
ccgus committed Jul 4, 2012
1 parent d065d5e commit 1777d2e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.markdown
Expand Up @@ -42,7 +42,7 @@ Before you can interact with the database, it must be opened. Opening fails if


### Executing Updates ### Executing Updates


Any sort of SQL statement which is not a `SELECT` statement qualifies as an update. This includes `CREATE`, `PRAGMA`, `UPDATE`, `INSERT`, `ALTER`, `COMMIT`, `BEGIN`, `DETACH`, `DELETE`, `DROP`, `END`, `EXPLAIN`, `VACUUM`, and `REPLACE` statements (plus many more). Basically, if your SQL statement does not begin with `SELECT`, it is an update statement. Any sort of SQL statement which is not a `SELECT` statement qualifies as an update. This includes `CREATE`, `UPDATE`, `INSERT`, `ALTER`, `COMMIT`, `BEGIN`, `DETACH`, `DELETE`, `DROP`, `END`, `EXPLAIN`, `VACUUM`, and `REPLACE` statements (plus many more). Basically, if your SQL statement does not begin with `SELECT`, it is an update statement.


Executing updates returns a single value, a `BOOL`. A return value of `YES` means the update was successfully executed, and a return value of `NO` means that some error was encountered. You may invoke the `-lastErrorMessage` and `-lastErrorCode` methods to retrieve more information. Executing updates returns a single value, a `BOOL`. A return value of `YES` means the update was successfully executed, and a return value of `NO` means that some error was encountered. You may invoke the `-lastErrorMessage` and `-lastErrorCode` methods to retrieve more information.


Expand Down
18 changes: 18 additions & 0 deletions src/fmdb.m
Expand Up @@ -69,6 +69,24 @@ int main (int argc, const char * argv[]) {
FMDBQuickCheck(([db boolForQuery:@"SELECT ? not null", [NSData data]])); FMDBQuickCheck(([db boolForQuery:@"SELECT ? not null", [NSData data]]));





// how do we do pragmas? Like so:
FMResultSet *ps = [db executeQuery:@"PRAGMA journal_mode=delete"];
FMDBQuickCheck(![db hadError]);
FMDBQuickCheck(ps);
FMDBQuickCheck([ps next]);
[ps close];

// oh, but some pragmas require updates?
[db executeUpdate:@"PRAGMA page_size=2048"];
FMDBQuickCheck(![db hadError]);

// what about a vacuum?
[db executeUpdate:@"vacuum"];
FMDBQuickCheck(![db hadError]);

exit(0);

// but of course, I don't bother checking the error codes below. // but of course, I don't bother checking the error codes below.
// Bad programmer, no cookie. // Bad programmer, no cookie.


Expand Down

0 comments on commit 1777d2e

Please sign in to comment.