aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cd.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/cd.c b/cd.c
index 7d0cb0b..9b87512 100644
--- a/cd.c
+++ b/cd.c
@@ -42,7 +42,7 @@ int main(int argc, char* argv[]) {
/* Get number of cards */
sqlite3_stmt *stmt;
rc = sqlite3_prepare_v3(db, "SELECT COUNT(*) FROM cards", -1, 0, &stmt, NULL);
- if (rc != SQLITE_OK) {
+ if (rc) {
fprintf(stderr, "Database error: %s\n", sqlite3_errmsg(db));
abort();
}
@@ -52,7 +52,7 @@ int main(int argc, char* argv[]) {
/* Get card weights */
rc = sqlite3_prepare_v3(db, "SELECT weight FROM cards", -1, 0, &stmt, NULL);
- if (rc != SQLITE_OK) {
+ if (rc) {
fprintf(stderr, "Database error: %s\n", sqlite3_errmsg(db));
abort();
}
@@ -83,7 +83,7 @@ int main(int argc, char* argv[]) {
/* Get card contents from database */
rc = sqlite3_prepare_v3(db, "SELECT key, val FROM cards WHERE idx=?", -1, 0, &stmt, NULL);
- if (rc != SQLITE_OK) {
+ if (rc) {
fprintf(stderr, "Database error: %s\n", sqlite3_errmsg(db));
abort();
}
@@ -115,12 +115,13 @@ int main(int argc, char* argv[]) {
/* Update segment tree and database */
update(i, w, 0, N - 1, 1);
rc = sqlite3_prepare_v3(db, "UPDATE cards SET weight=? WHERE idx=?", -1, 0, &stmt, NULL);
- if (rc != SQLITE_OK) {
+ if (rc) {
fprintf(stderr, "Database error: %s\n", sqlite3_errmsg(db));
abort();
}
sqlite3_bind_int(stmt, 1, w);
sqlite3_bind_int(stmt, 2, i);
+ sqlite3_step(stmt);
sqlite3_finalize(stmt);
}