[odb-users] SQL functions as values for certain columns on INSERT or UPDATE

Boris Kolpackov boris at codesynthesis.com
Tue Oct 25 00:53:18 EDT 2016

Hi Sten,

Sten Kultakangas <ratkaisut at gmail.com> writes:

> I want to set a column's value to a value returned by
> DATEADD(ss,-something,GETDATE()) on INSERT. Can this be achieved using
> standard ways without using execute() etc ?

No, you cannot "pass" database function calls to insert()/update()
operations. Your options are:

1. Use a view to call the function, fetch the result, and pass it as a
   normal value.

2. Use the function call as the column's default value (see pragma db
   default). Then insert/update NULL to trigger the use of the default

3. Similar to 3 but using INSERT/UPDATE triggers. For example, you could
   reserve some "special" values which the trigger detects.


More information about the odb-users mailing list