summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vincent Rischmann2021-01-01 17:47:38 +0100
committerGravatar Vincent Rischmann2021-01-01 17:47:38 +0100
commit281549e4cab07deb7fdd8fff6cdd13f0b2e4051e (patch)
tree0fb8fe8f83bd69ce81469ae6b2917058d6e55ba2
parentbuild: set the target (diff)
downloadzig-sqlite-281549e4cab07deb7fdd8fff6cdd13f0b2e4051e.tar.gz
zig-sqlite-281549e4cab07deb7fdd8fff6cdd13f0b2e4051e.tar.xz
zig-sqlite-281549e4cab07deb7fdd8fff6cdd13f0b2e4051e.zip
readme: document statement reuse
Fixes #3
-rw-r--r--README.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/README.md b/README.md
index dea6990..7f12093 100644
--- a/README.md
+++ b/README.md
@@ -102,6 +102,27 @@ try stmt.exec({
102 102
103See the section "Bind parameters and resultset rows" for more information on the types mapping rules. 103See the section "Bind parameters and resultset rows" for more information on the types mapping rules.
104 104
105## Reuse a statement
106
107You can reuse a statement by resetting it like this:
108```zig
109const query =
110 \\UPDATE foo SET salary = ? WHERE id = ?
111;
112
113var stmt = try db.prepare(query);
114defer stmt.deinit();
115
116var id: usize = 0;
117while (id < 20) : (id += 1) {
118 stmt.reset();
119 try stmt.exec(.{
120 .salary = 2000,
121 .id = id,
122 });
123}
124```
125
105## Reading data 126## Reading data
106 127
107For queries which return data you have multiple options: 128For queries which return data you have multiple options: