Home > Blockchain >  SQLite3: INSERT INTO statement error - unrecognized token/no such column
SQLite3: INSERT INTO statement error - unrecognized token/no such column

Time:06-30

I am trying to insert values in a table in Sqlite3, but unable to do so. Table name: orphan_dbis_consolidated_report

PRAGMA table_info(orphan_dbis_consolidated_report);

Schema Output is

0|Date|TEXT|1||0
1|Host|TEXT|1||0
2|Usage|TEXT|0||0
3|Port|TEXT|1||0
4|Wf_Context_Id|TEXT|0||1
5|Automation_Name|TEXT|1||0

So The Statement i am using to insert values is:

INSERT INTO orphan_dbis_consolidated_report (Date, Host, Usage, Port, Wf_Context_Id, Automation_Name) VALUES (‘2022-06-30’, ‘db167019.bwi101.service-now.com’, ‘Read_Replica’, ‘3400’, ‘8778405edb501d983050ac44d49619a5’, ‘Cid_CloneEngineContextCLN0535392’);

Now for above query i get Error: unrecognized token: "30’"

Note :

I have tried putting values in double quotes as well, in that case, i get error like column not found (it tries to assert given values as a column name and then says that column name does not exist)

Also I have tried to put column names in double quotes and values in single quotes, then i get error like: Error: table orphan_dbis_consolidated_report has no column named “Date”. Same case when I put column name in single quote.

Can anyone suggest what is wrong in this simple insert statement. Thanks

CodePudding user response:

You are using the Unicode codepoints 0x2018 and 0x2019 as single quotes: ‘...’ (LEFT SINGLE QUOTATION MARK, RIGHT SINGLE QUOTATION MARK).

Use the ASCII single quote instead: '.

INSERT INTO orphan_dbis_consolidated_report
    (Date, Host, Usage, Port, Wf_Context_Id, Automation_Name)
    VALUES ('2022-06-30', 'db167019.bwi101.service-now.com', 'Read_Replica', '3400', '8778405edb501d983050ac44d49619a5', 'Cid_CloneEngineContextCLN0535392');
--          ~          ~  ~                               ~  ~            ~  ~    ~  ~                                ~  ~                                ~

CodePudding user response:

make sure the insert value matches the data type, also review the columns in the database for the typo errors.

check if you have extra space. for example "DDD " after deleting space "DDD"

  • Related