You need 2 inserts to do what you want.  Hopefully the order in the table 
doesn't matter to you.



sqlite> CREATE TABLE t2 (Col1 text,Col2 text);
sqlite> insert into t2 (Col1) values('xxx');
sqlite> insert into t2 values('yyy','def');
sqlite> select * from t2;
xxx|
yyy|def
sqlite>
sqlite>
sqlite> CREATE TABLE t3 (Col1 text,Col2 text default 'abc');
sqlite> insert into t3 SELECT * FROM t2 where Col2 is not null;
sqlite> select * from t3;
yyy|def
sqlite> insert into t3 (Col1) SELECT Col1 FROM t2 where Col2 is null;
sqlite> select * from t3;
yyy|def
xxx|abc



Michael D. Black

Senior Scientist

Advanced Analytics Directorate

Advanced GEOINT Solutions Operating Unit

Northrop Grumman Information Systems

________________________________
From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of Pete [p...@mollysrevenge.com]
Sent: Wednesday, April 04, 2012 7:48 PM
To: sqlite-users@sqlite.org
Subject: EXT :[sqlite] Variation on INSERT with SELECT issue

The test this time was:

sqlite> create table t1 (Col1,Col2);
sqlite> insert into t1 (Col1) values ('xxx');
sqlite> select * from t1;
xxx|

sqlite> create table t2 (Col1, col2 not null default 'abc');
sqlite> insert into t2 SELECT * from t1;
SQL error: t2.col2 may not be NULL

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

Reply via email to