summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md24
1 files changed, 23 insertions, 1 deletions
diff --git a/README.md b/README.md
index e922f62..235cbc7 100644
--- a/README.md
+++ b/README.md
@@ -242,7 +242,29 @@ if (row) |row| {
242``` 242```
243Notice that to read text we need to use a 0-terminated array; if the `name` column is bigger than 127 bytes the call to `one` will fail. 243Notice that to read text we need to use a 0-terminated array; if the `name` column is bigger than 127 bytes the call to `one` will fail.
244 244
245The sentinel is mandatory: without one there would be no way to know where the data ends in the array. 245If the length of the data is variable then the sentinel is mandatory: without one there would be no way to know where the data ends in the array.
246
247However if the length is fixed, you can read into a non 0-terminated array, for example:
248
249```zig
250const query =
251 \\SELECT id FROM employees WHERE name = ?
252;
253
254var stmt = try db.prepare(query);
255defer stmt.deinit();
256
257const row = try stmt.one(
258 [16]u8,
259 .{},
260 .{ .name = "Vincent" },
261);
262if (row) |id| {
263 std.log.debug("id: {s}", .{std.fmt.fmtSliceHexLower(&id)});
264}
265```
266
267If the column data doesn't have the correct length a `error.ArraySizeMismatch` will be returned.
246 268
247The convenience function `sqlite.Db.one` works exactly the same way: 269The convenience function `sqlite.Db.one` works exactly the same way:
248 270