SQLITE_ERROR: sqlite3 result code 1: no such column:
(1) By bombshell on 2024-10-20 11:34:40 [link] [source]
CREATE TABLE JobCode (JobCodeID Integer, JobCodeDescription varchar(50), primary key (JobCodeID) ); Insert into JobCode values (1, "Customer Service Representative"); Insert into JobCode values (2, "Marketing specialist"); Insert into JobCode values (3, "Project manager"); Insert into JobCode values (4, "Order clerk"); Insert into JobCode values (5, "Web developer"); Insert into JobCode values (6, "Content writer");
Response getting is: SQLITE_ERROR: sqlite3 result code 1: no such column: "Customer Service Representative" - should this be a string literal in single-quotes?
(2.2) By Chris Locke (chrisjlocke1) on 2024-10-20 12:41:46 edited from 2.1 in reply to 1 [link] [source]
Try replacing the double-quotes with single quotes. It'll work then. Double-quotes means 'use this as a column name', not 'use this as a literal string'.
Eg
Insert into JobCode values (1, 'Customer Service Representative');
Then read #8 on this page. You may as well read the others too, as you're not familiar with SQLite.
https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted
(3) By bombshell on 2024-10-20 23:11:56 in reply to 2.2 [link] [source]
Thank you. But when I do that,I get: SQLITE_CONSTRAINT_PRIMARYKEY: sqlite3 result code 1555: UNIQUE constraint failed: JobCode.JobCodeID
(4) By Larry Brasfield (larrybr) on 2024-10-20 23:40:38 in reply to 3 [source]
You need to contrive a way to avoid attempting to insert a primary key value that is already in use.
A good way, I have often found, is to insert values other than the primary key and let the DBMS assign a new primary key.
(7) By bombshell on 2024-10-21 13:08:37 in reply to 4 [link] [source]
Thank you
(5) By Gunter Hick (gunter_hick) on 2024-10-21 05:48:54 in reply to 3 [link] [source]
INSERT INTO JobCode (JobCodeDescription) VALUES ('Customer Service Representative');
BTW:
CREATE TABLE JobCode(Id INTEGER PRIMARY KEY, Description TEXT);
Will explicitly use the Id as an alias for the internal rowid.
Also, consider that field names do not need to include the table name. If two (or more) tables with identically named fields (or the same table more than once) are present in the same SELECT statement, then it is probably necessary to assign aliases to tables and qualify field names with table aliases anyway.
(6) By bombshell on 2024-10-21 13:08:19 in reply to 5 [link] [source]
Thank you