Recent

Author Topic: [Solved] - Unexpected Token: 'AS', expected: 'SET'  (Read 268 times)

kholyphoenix1

  • New member
  • *
  • Posts: 5
[Solved] - Unexpected Token: 'AS', expected: 'SET'
« on: September 08, 2019, 12:00:57 pm »
Hello,
I'm new to Lazarus.
I have the following question. Why when I run this SQL is reporting this error?
He is not allowing me to put AS.


QuerySQL -> SQL
UPDATE acesso_historico AS ah, acesso_cadastro AS ac
SET ultimoAcesso = :ultimoAcesso
WHERE ac.usuario = :usuario
AND ah.id = ac.id   

Error:
Unexpected Token: 'AS', expected: 'SET'
« Last Edit: September 09, 2019, 10:53:54 pm by kholyphoenix1 »

fred

  • Full Member
  • ***
  • Posts: 151
Re: [Question] - Unexpected Token: 'AS', expected: 'SET'
« Reply #1 on: September 08, 2019, 12:24:36 pm »
I have no sql server at hand but I think UPDATE supports only one table, the AS must be used in a FROM statement.
Started with OmegaSoft Pascal on OS-9/68k , now Lazarus 2.0.4 / FPC 3.0.4 on Windows 7

ASerge

  • Hero Member
  • *****
  • Posts: 1408
Re: [Question] - Unexpected Token: 'AS', expected: 'SET'
« Reply #2 on: September 08, 2019, 12:43:19 pm »
QuerySQL -> SQL
UPDATE acesso_historico AS ah, acesso_cadastro AS ac
SET ultimoAcesso = :ultimoAcesso
WHERE ac.usuario = :usuario
AND ah.id = ac.id   
Unexpected Token: 'AS', expected: 'SET'
Only one table or view can appear in an update statement.

kholyphoenix1

  • New member
  • *
  • Posts: 5
Re: [Question] - Unexpected Token: 'AS', expected: 'SET'
« Reply #3 on: September 08, 2019, 01:01:40 pm »
How can I solve this?
Because I have 2 tables that interact between yes through the column 'matricula'.
What do I do?

fred

  • Full Member
  • ***
  • Posts: 151
Started with OmegaSoft Pascal on OS-9/68k , now Lazarus 2.0.4 / FPC 3.0.4 on Windows 7

kholyphoenix1

  • New member
  • *
  • Posts: 5
Re: [Question] - Unexpected Token: 'AS', expected: 'SET'
« Reply #5 on: September 08, 2019, 01:27:12 pm »
UPDATE acesso_historico
SET ultimoAcesso = :ultimoAceso
WHERE usuario = :usuario

(Error)
SQLQuery: Cannot open a non-select statement.

ASerge

  • Hero Member
  • *****
  • Posts: 1408
Re: [Question] - Unexpected Token: 'AS', expected: 'SET'
« Reply #6 on: September 08, 2019, 01:36:20 pm »
UPDATE acesso_historico
...
SQLQuery: Cannot open a non-select statement.
Open only to SELECT, for other - ExecSQL;