But you could use an INSERT trigger instead. Also "does contains no sub-queries" ought to "doesn't contain any sub-queries", shouldn't it?
Peter On Monday, June 20, 2016 5:55 PM, Peter Aronson <pbaron...@att.net> wrote: According to https://www.sqlite.org/lang_createtable.html: "An explicit DEFAULT clause may specify that the default value is NULL, a string constant, a blob constant, a signed-number, or any constant expression enclosed in parentheses. A default value may also be one of the special case-independent keywords CURRENT_TIME, CURRENT_DATE or CURRENT_TIMESTAMP. For the purposes of the DEFAULT clause, an expression is considered constant if it does contains no sub-queries, column or table references, bound parameters, or string literals enclosed in double-quotes instead of single-quotes." So that explains why random() works but your hash() does not. Peter On Monday, June 20, 2016 5:47 PM, Jörgen Hägglund <jor...@sirlucifer.mine.nu> wrote: Alright, trying to set the scenario: * I open/create a database * I register a custom function called HASH (set to be deterministic), tested and working * I create a bunch of tables (if not exists) So far, everything works fine. Then, the troublesome create: CREATE TABLE IF NOT EXISTS Programmes ( ID NVARCHAR(64) UNIQUE NOT NULL PRIMARY KEY DEFAULT (HASH(Title, Year, EpNo2)), Title NVARCHAR(100) NOT NULL, Description NVARCHAR(1000), Year NVARCHAR(10), EpNo1 NVARCHAR(50), EpNo2 NVARCHAR(100)) This query raises the following exception: Unable to create table default value of column [ID] is not constant Is it not possible to use custom functions this way? I tried with random() on another table and that works. Any ideas and explanations would be appreciated. /Jörgen _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users