On Sun, Feb 21, 2016 at 6:09 PM, Olivier Mascia <om at integral.be> wrote:

> Dear all,
>
> Is it possible to implement a SQL function (
> https://www.sqlite.org/c3ref/create_function.html), which implementation
> would be able to return the same value for the duration of the current
> transaction?
>

This _might_ suffice for you, but maybe not: the SQLITE_DETERMINISTIC flag
for sqlite3_create_function().

Copied from the header file:


 ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC]
** to signal that the function will always return the same result given
** the same inputs within a single SQL statement.  Most SQL functions are
** deterministic.  The built-in [random()] SQL function is an example of a
** function that is not deterministic.  The SQLite query planner is able to
** perform additional optimizations on deterministic functions, so use
** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.

Note that it says within a single statement, not a transaction.

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf

Reply via email to