SQLite Forum

Not seeing error, fresh eyeballs may help
Login

Not seeing error, fresh eyeballs may help

(1) By Rich S (richs) on 2020-04-02 23:48:31 [link] [source]

Trying to load table data in a database produces an error that I do not find.

The error is:
$ sqlite3 testing.db < biota.sql
Error: near line 1: near ",": syntax error

The first two lines of the data file are:

insert into Biota sampid,site_id,sampdate,tclass,torder,tfamily,tgenus,tspecies,subspecies,common_name,ffg,quant) values 
(1,11,'2000-07-18','Annelida','Oligochaeta','Tubificidae',,,,,'Gatherer',22),

N.B.: there is not a newline after Biota in the data file.

There are 12 column names listed and 12 pieces of data. What have I missed seeing?

(2) By Warren Young (wyoung) on 2020-04-02 23:53:53 in reply to 1 [link] [source]

No open paren before the field list.

(3) By Keith Medcalf (kmedcalf) on 2020-04-03 00:02:52 in reply to 1 [link] [source]

Your values list is missing values. That is you cannot do:

insert into ... values (1,2,3,,,,4);

if you mean:

insert into ... values (1,2,3,null,null,null,4);

then you need to be saying that. Two commas side-by-each is a syntax error.

(4) By Rich S (richs) on 2020-04-03 00:06:47 in reply to 3 [link] [source]

Keith,

Oh. I didn't realize that. That's a quick fix.

Thanks,

Rich

(5.2) By David Jones (vman59) on 2020-04-03 00:22:07 edited from 5.1 in reply to 3 [source]

Unless it's a virtual table constructor function, it allows (a,,,b,c) with non-intuitive results.

(6) By Rich S (richs) on 2020-04-03 00:38:44 in reply to 4 [link] [source]

Actually, I should have known that because it is the same with postgres. It's been a while and I just plain spaced it. No excuse.

(7) By Rich S (richs) on 2020-04-03 00:39:31 in reply to 2 [link] [source]

There is, but it got lost when I pasted the text in this forum box.

Regards,

Rich