Skip to content

Commit c74c5df

Browse files
committed
Merge pull request #89 from zauguin/functions
2 parents 1ba1ef4 + 5f421c2 commit c74c5df

File tree

3 files changed

+429
-3
lines changed

3 files changed

+429
-3
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,25 @@ sqlite::sqlite_exception has a get_code() member function to get the SQLITE3 err
304304
catch(sqlite::exceptions::constraint e) { } */
305305
```
306306

307+
Custom SQL functions
308+
----
309+
310+
To extend SQLite with custom functions, you just implement them in C++:
311+
312+
```c++
313+
database db(":memory:");
314+
db.define("tgamma", [](double i) {return std::tgamma(i);});
315+
db << "CREATE TABLE numbers (number INTEGER);";
316+
317+
for(auto i=0; i!=10; ++i)
318+
db << "INSERT INTO numbers VALUES (?);" << i;
319+
320+
db << "SELECT number, tgamma(number+1) FROM numbers;" >> [](double number, double factorial) {
321+
cout << number << "! = " << factorial << '\n';
322+
};
323+
```
324+
325+
307326
NDK support
308327
----
309328
Just Make sure you are using the full path of your database file :

0 commit comments

Comments
 (0)