Recent

Author Topic: [sqlite] simple query - error  (Read 10220 times)

wht244

  • Jr. Member
  • **
  • Posts: 79
[sqlite] simple query - error
« on: October 27, 2010, 07:26:31 am »
i have a problem with a simple query:
Code: [Select]
SELECT nazwisko FROM handlowcy WHERE id = 1 LIMIT 0, 1in sqlite database browser this query returns what i want, but if i try to execute that query with lazarus:
Code: [Select]
query.SQL.Text := 'SELECT nazwisko FROM handlowcy WHERE id = 1 LIMIT 0, 1';
try
  query.Open;
finally
  query.Close;
end;
i get an error:
Code: [Select]
near: LIMIT syntax erroror something like this.
any suggestions how to deal with it?
i'm using components from SQLdb tab (built-in)

gastonx

  • Newbie
  • Posts: 5
Re: [sqlite] simple query - error
« Reply #1 on: October 27, 2010, 10:32:54 am »
Which database?
MSSQL or mySQL?
MSSQL has no LIMIT function. Only TOP.

Lacak2

  • Guest
Re: [sqlite] simple query - error
« Reply #2 on: October 27, 2010, 10:58:41 am »
Which version of FPC ?
There was patch 5 months ago, which adds handling of LIMIT keyword into SQLParser see http://bugs.freepascal.org/view.php?id=15456

wht244

  • Jr. Member
  • **
  • Posts: 79
Re: [sqlite] simple query - error
« Reply #3 on: October 27, 2010, 02:43:45 pm »
how to install this patch?

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: [sqlite] simple query - error
« Reply #4 on: October 27, 2010, 07:00:31 pm »
try that;
query.SQL.Text := 'SELECT nazwisko FROM handlowcy WHERE id = 1 LIMIT 1'; :D

Lacak2

  • Guest
Re: [sqlite] simple query - error
« Reply #5 on: October 28, 2010, 05:07:26 am »
how to install this patch?
You can download daily snapshot of Lazarus with FPC 2.5.1 from ftp://www.hu.freepascal.org/pub/lazarus/snapshots/

wht244

  • Jr. Member
  • **
  • Posts: 79
Re: [sqlite] simple query - error
« Reply #6 on: October 28, 2010, 05:41:49 am »
i set field ParseSQL of TSQLQuery to false and that helped me a lot.
but i encountered other problem. query:
Code: [Select]
UPDATE handlowcy SET nazwisko = 'test' WHERE id = 1 LIMIT 1is also interpreted as it has error with syntax near LIMIT.

Lacak2

  • Guest
Re: [sqlite] simple query - error
« Reply #7 on: October 28, 2010, 06:54:52 am »
Do you use Filter or ServerFilter properties of SQLQuery component ?
Is SQLQuery in master-detail relationship with another component ?

wht244

  • Jr. Member
  • **
  • Posts: 79
Re: [sqlite] simple query - error
« Reply #8 on: October 28, 2010, 01:45:24 pm »
Filter and ServerFilter are not used.
Only relationships are TSQLTransaction and TSQLite3Connection.

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: [sqlite] simple query - error
« Reply #9 on: October 28, 2010, 05:58:41 pm »
Quote
UPDATE handlowcy SET nazwisko = 'test' WHERE id = 1 LIMIT 1

just no limit while id = 1
UPDATE handlowcy SET nazwisko = 'test' WHERE id = 1

Quote
Filter and ServerFilter are not used.
Only relationships are TSQLTransaction and TSQLite3Connection.
yes

 

TinyPortal © 2005-2018