This is a feature (or a bug, depending on your view). A column default must be
a constant, so your reference to "AppID" is translated to the string 'AppID'
because it cannot be a column name since that would not be a constant. Perhaps
your intent to do the following:
CREATE TABLE tApplicationPaths (
AppID INTEGER PRIMARY KEY,
ApplicationName CHAR,
ApplicationMonitorPath CHAR,
SearchSubDirs BOOL DEFAULT 1,
SearchMask CHAR);
CREATE TRIGGER tApplicationPathsInsert
AFTER INSERT ON tApplicationPaths
WHEN new.SearchMask is NULL
BEGIN
UPDATE tApplicationPaths SET SearchMask = CAST(AppID as CHAR) WHERE AppID =
new.AppID;
END;
insert into tApplicationPaths (ApplicationName, ApplicationMonitorPath) values
('Name', 'Monitor');
select * from tApplicationPaths;
1|Name|Monitor|1|1
If you use this format in your CREATE TABLE you get a meaningful error message:
CREATE TABLE tApplicationPaths (
AppID INTEGER PRIMARY KEY,
ApplicationName CHAR,
ApplicationMonitorPath CHAR,
SearchSubDirs BOOL DEFAULT 1,
SearchMask CHAR DEFAULT ([AppID]));
Error: default value of column [SearchMask] is not constant
---
() ascii ribbon campaign against html e-mail
/\ www.asciiribbon.org
> -----Original Message-----
> From: [email protected] [mailto:sqlite-users-
> [email protected]] On Behalf Of Stephen Chrzanowski
> Sent: Sunday, 19 May, 2013 18:05
> To: General Discussion of SQLite Database
> Subject: [sqlite] Create Table oddity
>
> I've been talking with Bogdan about a change to SQLite Expert and ran
> across something I did NOT expect.
>
> I have this schema:
>
> CREATE TABLE [tApplicationPaths] (
> [AppID] INTEGER PRIMARY KEY,
> [ApplicationName] CHAR,
> [ApplicationMonitorPath] CHAR,
> [SearchSubDirs] BOOL DEFAULT 1,
> [SearchMask] CHAR DEFAULT AppID);
>
> When I insert a new row, I get the literal string "AppID" as a default
> value for that new row. I was expecting a number or null, or something.
> Not a string. Is this intended behavior?
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users