[Peter Aronson]

> (2) You can associate data with an argument to a regular user-defined
> function using sqlite3_set_auxdata() and sqlite3_get_auxdata() as long
> as the value of the argument is static.  If you don't normally have a
> static argument to your function, you can add one (say a string
> MAVG').  I actually used this approach with some application generated
> SQL in my current project at one point.

Thanks.  I'm intending to write a function so I can do:

SELECT unix_time, mavg(value, unix_time, <period>) FROM tab;

assuming:

CREATE TABLE tab (value REAL, unix_time INTEGER, PRIMARY KEY (unix_time));

So I assume that your second approach could work, since the third
argument to mavg() (the period, window size in seconds) is static,
e.g. mavg(value, unix_time, 86400) will give me the moving daily
average.

But will the data be private to only one query?  That is, if two
queries using the same period happen to run simultaniously, will it
still work?  The documentation wasn't clear.  In its example of using
this data for storing a compiled regexp, it would rather be useful if
it was not strictly private.

-- 
Steinar
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to