Unexpected token: [ in statement [UPDATE ] in a seemingly okay Update Statement

I have an SQL Update statement in macro that fires a Unexpected token: [ in statement [UPDATE ] error even though I don’t see anything wrong. Here’s my code:

	Conn2 = Db.getConnection("","") 
    	strSQL2 = "UPDATE [Users] SET [Status] = 'on' where [ID] = 1;"
   		Stmt2 = Conn2.createStatement()
    	Stmt2.executeQuery(strSQL2) 'runtime gets interrupted here 
                                    'then fires the previously mentioned error

[Users] is the name of my table and [Status] is one of its columns.
Am I missing something here?

=========================
Version: 7.3.5.2 (x86) / LibreOffice Community
Build ID: 184fe81b8c8c30d8b5082578aee2fed2ea847c01
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: en-US (en_PH); UI: en-US
Calc: CL
DB in use: HSQLDB embedded

Hello,
Do not use square brackets to surround table and field names. This may work in queries but update doesn’t like them. If field names are all caps you need not surround them with quotes. Mixed or lower you do. For a string definition you need to use double quotes. Example:

strSQL2 = "UPDATE ""Users"" SET ""Status"" = 'on' where ""ID"" = 1"

.
BTW, double quotes not needed around ID - works with or without. That version of HSQLDB recognizes names as all caps if not quoted. Some other DB’s recognizes then as all lower. A good reason to note what DB you are using.

1 Like

That solved well! Thank you!

@hadjiamit
Will correct previous answer as that had square brackets an as just tested will give an error also. Strange that Insert allows them but not Update.
.
No previous notice as I tend to use quotes.