my problem is, that I wrote an update, checked it in SQLiteStudio, it works fine. When I execute the same in my program, it throws a syntax error. ('near "FROM": syntax error')
There is a difference in the sqlite3.dlls, because SQLiteStudio uses a 64bit one, my code is a 32bit Windows application, so it uses a 32bit dll. I found already some little differences (e.g. parenthesis is accepted or not) earlier in the function of the two versions, but there was always a solution to avoid the problem. (Unfortunately I don't know any exact version number, but the 32bit version is digitally signed by Idera Inc. in 20. February 2021., it is included by Delphi 10.4 Community version.)
But this time I have no idea, what can be the problem.
The original form of my UPDATE is:
UPDATE wRoutes SET tfFeedPt = fitt.tid FROM
(SELECT wr.id AS wid, tf.id AS tid FROM wRoutes wr
JOIN xyposFitt tf
ON wr.posX = tf.posX AND wr.posY = tf.posY
AND wr.drNum = tf.drNum AND wr.page = tf.page
WHERE endpoint = "X") AS fitt
WHERE wRoutes.id = fitt.wid
It's perferct in SQLiteStudio, but throws the mentioned exception from my code.
I searched in Google a lot, and found a tip which seemed to be promising - to use the WITH UPDATE form, so I tried this version too:
WITH fitt AS
(SELECT wr.id AS wid, tf.id AS tid FROM wRoutes wr
JOIN xyposFitt tf
ON wr.posX = tf.posX AND wr.posY = tf.posY
AND wr.drNum = tf.drNum AND wr.page = tf.page
WHERE endpoint = "X")
UPDATE wRoutes SET tfFeedPt = fitt.tid
FROM fitt
WHERE wRoutes.id = fitt.wid
It worked again in SQLiteStudio, but not in my code. I tried the table name aliases with and without using "AS". E.g. "FROM wRoutes wr" and "FROM wRoutes AS wr". The result is the same: SQLiteStudio OK, my code: 'near "FROM": syntax error'.
Could somebody tell, what is wrong with my UPDATE command?
Thank you in advance.