Recent

Author Topic: Query with no result  (Read 362 times)

Miflon

  • New Member
  • *
  • Posts: 10
Query with no result
« on: August 26, 2023, 02:26:01 pm »
Hi every one.
W10 win64; Lazarus 2.2.2; fpc 3.2.2; postgresql
What is the postgresql error code when a query returns no result?
Thanks for your replies.

Чебурашка

  • Sr. Member
  • ****
  • Posts: 487
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: Query with no result
« Reply #1 on: August 26, 2023, 03:03:35 pm »
There is no error as it is normal that certain queries have 0 records of result. Simply you have to check query.EOF before accessing the fields of the result.
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

TRon

  • Hero Member
  • *****
  • Posts: 1852
Re: Query with no result
« Reply #2 on: August 26, 2023, 04:59:46 pm »
As stated by Чебурашка, there is no error code returned because a query returning zero results is perfectly valid so use the suggested method or alternatively you could use IsEmpty

Miflon

  • New Member
  • *
  • Posts: 10
Re: Query with no result
« Reply #3 on: August 27, 2023, 10:46:20 am »
Thanks to you both. I think I'l do a try to IsEmpty.
« Last Edit: August 27, 2023, 10:48:17 am by Miflon »

 

TinyPortal © 2005-2018