Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQLite syntax error that I can't figure out - SOLVED

SQLite syntax error that I can't figure out - SOLVED

Scheduled Pinned Locked Moved Database
databasesqlitecomhelpquestion
3 Posts 2 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Richard Andrew x64R Offline
    Richard Andrew x64R Offline
    Richard Andrew x64
    wrote on last edited by
    #1

    I'm pulling my hair with this one: (There's a unique index on the [DOMAIN] field.

    INSERT INTO DNSLOG ([DATETIME], [DOMAIN], [BLOCKED]) VALUES (133436157350078746, 'optimizationguide-pa.googleapis.com.', 0)
    ON CONFLICT (DOMAIN) DO
    UPDATE DNSLOG
    SET HITCOUNT = HITCOUNT + 1
    WHERE DOMAIN = 'optimizationguide-pa.googleapis.com.'

    The error is clearly in the ON CONFLICT clause because when I run only the INSERT clause, it does what it's supposed to do. And the UPDATE statement works when I run it by itself. The actual error message is "SQL Logic error near "DNSLOG" syntax error". Any idea what the syntax error could be? ****SOLUTION**** It's not supposed to have the table name in the "DO UPDATE" statement. IOW:

    INSERT INTO DNSLOG ([DATETIME], [DOMAIN], [BLOCKED]) VALUES (133436157350078746, 'optimizationguide-pa.googleapis.com.', 0)
    ON CONFLICT (DOMAIN) DO
    UPDATE SET HITCOUNT = HITCOUNT + 1
    WHERE DOMAIN = 'optimizationguide-pa.googleapis.com.'

    The difficult we do right away... ...the impossible takes slightly longer.

    K 1 Reply Last reply
    0
    • Richard Andrew x64R Richard Andrew x64

      I'm pulling my hair with this one: (There's a unique index on the [DOMAIN] field.

      INSERT INTO DNSLOG ([DATETIME], [DOMAIN], [BLOCKED]) VALUES (133436157350078746, 'optimizationguide-pa.googleapis.com.', 0)
      ON CONFLICT (DOMAIN) DO
      UPDATE DNSLOG
      SET HITCOUNT = HITCOUNT + 1
      WHERE DOMAIN = 'optimizationguide-pa.googleapis.com.'

      The error is clearly in the ON CONFLICT clause because when I run only the INSERT clause, it does what it's supposed to do. And the UPDATE statement works when I run it by itself. The actual error message is "SQL Logic error near "DNSLOG" syntax error". Any idea what the syntax error could be? ****SOLUTION**** It's not supposed to have the table name in the "DO UPDATE" statement. IOW:

      INSERT INTO DNSLOG ([DATETIME], [DOMAIN], [BLOCKED]) VALUES (133436157350078746, 'optimizationguide-pa.googleapis.com.', 0)
      ON CONFLICT (DOMAIN) DO
      UPDATE SET HITCOUNT = HITCOUNT + 1
      WHERE DOMAIN = 'optimizationguide-pa.googleapis.com.'

      The difficult we do right away... ...the impossible takes slightly longer.

      K Offline
      K Offline
      k5054
      wrote on last edited by
      #2

      There is no DO option for ON CONFLICT: [The ON CONFLICT Clause](https://www.sqlite.org/lang\_conflict.html)

      Keep Calm and Carry On

      Richard Andrew x64R 1 Reply Last reply
      0
      • K k5054

        There is no DO option for ON CONFLICT: [The ON CONFLICT Clause](https://www.sqlite.org/lang\_conflict.html)

        Keep Calm and Carry On

        Richard Andrew x64R Offline
        Richard Andrew x64R Offline
        Richard Andrew x64
        wrote on last edited by
        #3

        Thanks for your response. What about this page? This says that there is: SQLite Syntax: upsert-clause[^] This is the INSERT statement, it clearly shows the upsert clause: SQLite Syntax: insert-stmt[^]

        The difficult we do right away... ...the impossible takes slightly longer.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups