On 10/20/08, Kenneth McDonald <[EMAIL PROTECTED]> wrote:
> Basically, my database INSERT commands seem to still expect a value
>  for this, even though my expectation is that it will be computed
>  automatically, starting with (I assume) a default of 0 or 1. But I'm
>  getting errors of the sort "table images has 12 columns but 11 values
>  were supplied." Is there something else I need to do to have the
>  primary key column computed automatically?

1. You don't have to specify ASC AUTOINCREMENT. Just saying INTEGER
PRIMARY KEY does all that for you;

2. You do have to specify what cols you are updating. Given that you
have not provided your SQL as an example, consider the following --

CREATE TABLE foo (a INTEGER PRIMARY KEY, b TEXT);
INSERT INTO foo VALUES ('some string');

How should the database know where to stuff that 'some string'?

You could do any of the following and get your desired behavior --

INSERT INTO foo (b) VALUES ('some string');

or

INSERT INTO foo VALUES (null, 'some string');

or

INSERT INTO foo (a, b) VALUES (null, 'some string');

or

INSERT INTO foo (a, b) VALUES (10034, 'some string');

In the last case, 10034 would be inserted into col 'a', but if 10034
already existed, the program would croak. In all other cases, the
effect would the same as

UPDATE foo SET a = Max(a) + 1;

>
>  Thanks,
>  Ken
>  _______________________________________________
>  sqlite-users mailing list
>  sqlite-users@sqlite.org
>  http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
Puneet Kishor http://punkish.eidesis.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to