Skip to main content
Cadet | Tier 2
March 31, 2022
Solved

How to solve "There is a syntactical error in the SQL statement."

  • March 31, 2022
  • 14 replies
  • 4101 views

User is able to connect to database, do select queries but all insert queries got the same error.

 

Using Automation Anywhere 360 version an as database Access

    Best answer by donvnielsen

    I am to blame for my problems. Forget everything I said previously. Let me illustrate what I done and how the problem came to be:

    • My application opens with a bot to create a connection to the database
    • This bot calls into a child bot to look for an existing database or create one
      • This child bot did not find the database
      • Child bot assemble the file name with elements passed to it and a global environment variable
      • Child bot created and initialized db with all the table structures
      • Control is returned to the caller
    • The caller (create a connection) then attempts connection to the db (or so I thought)
      • It built the file name, but the file name lacked the environment
      • sqlite would create an empty db in memory, but not commit it to the file system
      • My bot then tried to insert into a table that did not exist; this caused the time out
      • Because there was no change to the db, sqlite did not save it to file system. So the errant db was not visible.

    So, basically, I was looking in the db (environment in file name) and everything would look fine. There was no copy of the errant db because it would disappear. I had to catch it. This was slipped by me, even when debugging line by line.

    The fix was to move all file name elements (credentials) into the child bot and the child would send back to the caller the file name it had assembled. The caller would then connect to the db and initialize the database session correctly.

    I was to blame. 

    14 replies

    Navigator | Tier 3
    August 19, 2024

    There’s something here, fine people. I have encountered this today. I created is a logger using Sqlite as my file system. It works fine in Community Edition (CE), but it fails in Enterprise Edition (EE). The sql statement is as follows:

    INSERT INTO ApplicationSessions (ApplicationName,ServerName,StartDateTime,LoggedBy) VALUES ('CreateApplicationSession','mfdaabc3','2024-08-19 14:25:12.833','niedo');

    And the table structure is as follows:

    CREATE TABLE IF NOT EXISTS "ApplicationSessions"
    (
        Id              INTEGER
            constraint ApplicationSessions_pk
                primary key autoincrement,
        ApplicationName TEXT collate NOCASE not null,
        ServerName      TEXT collate NOCASE not null,
        StartDateTime   TEXT collate NOCASE,
        EndDateTime     TEXT collate NOCASE,
        LoggedBy        Text default ''
    );

    CREATE TRIGGER IF NOT EXISTS StandardizeApplicationSession
       AFTER INSERT ON ApplicationSessions
        BEGIN
            UPDATE ApplicationSessions SET 
                ApplicationName = Trim(ApplicationName)
                , ServerName = Trim(ServerName)
                , LoggedBy = Upper(Trim(LoggedBy)) 
            WHERE ROWID = new.ROWID;
        END;

    The insert statement also works from the sqlite3 command line app. But when I test the system using my account in EE, then I get “There is a syntactical error in the SQL statement. - SQL statement got timed out.”


    Things I have tried:
    _ setting time out seconds
    _ making sure there is no unnecessary whitespace in the insert command
    _ making sure there was a semi-colon at the end of the statement
    _ reworking the create table syntax so there was no unnecessary whitespace in that (looking for anything)
    _ i dropped the trigger
    _ destroying the database and building it by hand ahead of bot testing

    I’ll add more detail, trial and errors as I continue to work this. Real head scratcher.

    Navigator | Tier 3
    August 20, 2024

    Replying to my own post. Unfortunately, it is not a solution. It just more details of what I have attempted.

    I abandoned my bot framework and just cobbled together a simple bot that has just the necessary statements to open, insert, end. (My thought process was that maybe the database session variable was getting corrupted being passed around to the various bots.) But it results with the same time out error:

    I have confirmed the following: the database file does exist (no brainer), the table does exist, the actual insert does work within sqlite3.exe. There are no permissions with a sqlite database unlike server based databases. If you can connect to it, you can use it.

    Note in the image above there are two “Database: Insert...” tasks. The first one executes; it is a PRAGMA statement for database control. It executes fine. The second one is the INSERT failure.

    I have also connected to the database file using JetBrains sqlite driver and there are no issues.

     

    Again, my problems are with the Enterprise Edition and not Community Edition. It appears to be the jdbc adapter that is employed by AA. I can’t think of any other reason for the problem. There appears to be a real problem, here. What URL should I use to log an official bug report with Automation Anywhere?

    Thank you all for your time and consideration, dvn

    Navigator | Tier 3
    August 23, 2024

    I am to blame for my problems. Forget everything I said previously. Let me illustrate what I done and how the problem came to be:

    • My application opens with a bot to create a connection to the database
    • This bot calls into a child bot to look for an existing database or create one
      • This child bot did not find the database
      • Child bot assemble the file name with elements passed to it and a global environment variable
      • Child bot created and initialized db with all the table structures
      • Control is returned to the caller
    • The caller (create a connection) then attempts connection to the db (or so I thought)
      • It built the file name, but the file name lacked the environment
      • sqlite would create an empty db in memory, but not commit it to the file system
      • My bot then tried to insert into a table that did not exist; this caused the time out
      • Because there was no change to the db, sqlite did not save it to file system. So the errant db was not visible.

    So, basically, I was looking in the db (environment in file name) and everything would look fine. There was no copy of the errant db because it would disappear. I had to catch it. This was slipped by me, even when debugging line by line.

    The fix was to move all file name elements (credentials) into the child bot and the child would send back to the caller the file name it had assembled. The caller would then connect to the db and initialize the database session correctly.

    I was to blame. 

    Cadet | Tier 2
    April 8, 2025

    We ran into similar Issue . The DB was running out of space . Once we updated the Storage for the DB . The issue is resolved.