On Sat, 02 Aug 2008 13:51:15 +0100, you wrote:

>Hi,
>
>I am using SQLite 3.6.0 under Windows. I created a table using the 
>following schema (prev used in another DB hence Varchars etc.) :
>
>CREATE TABLE CurrentValues (
> Time_Stamp DATETIME DEFAULT CURRENT_TIMESTAMP,
> Sensor_ID WORD DEFAULT 1 NOT NULL,
> Sensor_Name VARCHAR(20),
> Sensor_Type VARCHAR(8),
> Sensor_Value FLOAT DEFAULT 0 NOT NULL,
> Sensor_Units VARCHAR(15) DEFAULT 'NotSet' NOT NULL,
> Location VARCHAR(20),
> Alarm LOGICAL DEFAULT False,
>PRIMARY KEY (Sensor_ID));
>
>Initially the default values for Time_Stamp and Alarm worked as expected 
>but Sensor_Value and Sensor_Units inserted nothing at all.
>
>I changed the Sensor_ID's type from WORD to INTEGER and this column now 
>inserts the default value. I changed the Sensor_Units' type to TEXT and 
>it made no difference.
>
>Can anyone see why my default text value doesn't work?

It works for me:

sqlite_version():3.6.0 (on Windows)

CREATE TABLE CurrentValues (
 Time_Stamp DATETIME DEFAULT CURRENT_TIMESTAMP,
 Sensor_ID INTEGER DEFAULT 1 NOT NULL,
 Sensor_Name VARCHAR(20),
 Sensor_Type VARCHAR(8),
 Sensor_Value FLOAT DEFAULT 0 NOT NULL,
 Sensor_Units VARCHAR(15) DEFAULT 'NotSet' NOT NULL,
 Location VARCHAR(20),
 Alarm LOGICAL DEFAULT False,
 PRIMARY KEY (Sensor_ID)
);

INSERT OR REPLACE INTO CurrentValues
(Sensor_ID,Sensor_Name,Sensor_Type,Location) 
VALUES (4,'S4','Temp','Kitchen');

INSERT OR REPLACE INTO CurrentValues
(Sensor_ID,Sensor_Name,Sensor_Type,Sensor_Value,Sensor_Units)
VALUES (5,'S5','Temp',293.5,'K');

.headers on
.nullvalue '<NULL>'
SELECT * FROM CurrentValues;
Time_Stamp|Sensor_ID|Sensor_Name|Sensor_Type|Sensor_Value|Sensor_Units|Location|Alarm
2008-08-02 18:33:12|4|S4|Temp|0.0|NotSet|Kitchen|False
2008-08-02 18:33:13|5|S5|Temp|293.5|K|<NULL>|False

>David Goadby
-- 
  (  Kees Nuyt
  )
c[_]
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to