Firedac errors

767 views
Skip to first unread message

Midsoft UK

unread,
Jul 8, 2021, 5:12:07 AM7/8/21
to firebird-support
Hi all
is there a way to get better error messages form FireDac ?
For example I have no way of knowing without trial and error which query the issue below refers to. I would have expected the query name in the message.
--------------------------
[FireDAC][Phys][FB]Dynamic SQL Error

SQL error code = -206

Column unknown

JOBNO

At line 2, column 7.
---------------------------
OK   
---------------------------
Thanks

Jason (PN)

unread,
Jul 8, 2021, 5:39:01 AM7/8/21
to firebird...@googlegroups.com

How about adding something like this to the FDConnection event OnError?

I am hoping it fires on all exceptions that are generated via the connection.

 

procedure TForm2.FDConnection1Error(ASender, AInitiator: TObject; var

    AException: Exception);

begin

  if (AInitiator <> nil) then

    if AInitiator is Tcomponent then

      AException.Message:='Error: '+Tcomponent(AInitiator).Name+' threw a wobbly'+crlf+AException.message;

 

Jason Chapman

JAC2 Consultancy Limited

Mob: 07966211959

--
You received this message because you are subscribed to the Google Groups "firebird-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebird-suppo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/firebird-support/0864091e-8027-436b-8fae-e0d976e7fcfbn%40googlegroups.com.

Tomasz Tyrakowski

unread,
Jul 8, 2021, 7:32:31 AM7/8/21
to firebird...@googlegroups.com
Apart from the answer posted earlier by Jason, if you run your
application from within the Embarcadero IDE, it stops whenever an
exception pops up, and you can check the full call stack and identify
the precise spot where the exception was raised (and the caller of that
routine, and the caller of the caller, etc., finally arriving at your
code that was the actual source of the problem). Setting a proper
breakpoint will allow you to inspect the exact query string that caused
the exception before it gets executed. So there's no "trial and error",
just use the debugger.
I use IBObjects to access the DB, which provide the query component name
in the error message, but it usually doesn't help much, as query objects
are often reused multiple times, and at the end of the day the debugger
is still the best option.

cheers
Tomasz
________________________________


Ta wiadomość zawiera poufne informacje przeznaczone tylko dla adresata. Jeżeli nie jesteście Państwo jej adresatem, bądź otrzymaliście ją przez pomyłkę, prosimy o powiadomienie o tym nadawcy oraz trwałe jej usunięcie.

Karol Bieniaszewski

unread,
Jul 8, 2021, 8:42:07 AM7/8/21
to firebird...@googlegroups.com

First of all do not multipost– you have asked here as „better error messages”

And you got an answer from Mark Rotteveel.

 

I really do not understand your problem. You are the autor of the application?

If yes, simply add try except when you open some query.

e.g.:

 

fdquery1.SQL.Text:= ‘SELECT 1/0 FROM RDB$DATABASE’;

try

   fdquery1.open;

except

   on E: Exception do

      begin

         E.Message:= E.Message + sLineBreak + fdquery1.SQL.Text;

          Raise;

      end

end;  

 

you got full sql query text in error message.

You can also create procedure like FDOpen(FDQuery: TFDQuery) with above code to use it in avery places.

 

Regards,

Karol Bieniaszewski

--

Midsoft UK

unread,
Jul 8, 2021, 9:25:39 AM7/8/21
to firebird-support
Hi

I didn't know the two groups were connected so no idea it was cross posting. Google is big !

Your suggestion is what we have resorted to for now.  We are used to ADS always giving the component name in their errors and were interested to find out if Firedac could do the same

Andy

fernande...@gmail.com

unread,
Jul 8, 2021, 9:35:28 AM7/8/21
to firebird...@googlegroups.com

I have converted from ADS to firebird/firedac, how are you running the SQL script. TFDQuery?

Does the query run in a DB editor?

Might be a problem with Field mapping to a component.

 

Regards

 

 

Flavius Fernandes

Founder |Solution & Software Architect

ERPSirius UK

https://www.erpsirius.co.uk/

https://www.linkedin.com/in/flavius-fernandes-50467b22/

Midsoft UK

unread,
Jul 8, 2021, 9:39:14 AM7/8/21
to firebird-support

Hi Falavious

You will notice that ADS shows errors like "AdsQuery1 error 5305, record locked..." or 7200 SQL error.
Yes we are using TFDQuery. Its no big deal if it doesn't do it now we know, we can handle it another way.

Mark Rotteveel

unread,
Jul 8, 2021, 9:55:45 AM7/8/21
to firebird...@googlegroups.com
On 2021-07-08 15:25, Midsoft UK wrote:
> I didn't know the two groups were connected so no idea it was cross
> posting. Google is big !

Which two groups? You posted both to the firebird-support Google Group.

Mark

Midsoft UK

unread,
Jul 8, 2021, 12:29:19 PM7/8/21
to firebird-support
Ah, I'd thought I'd selected the delphi FireDac group. My mistake.

Midsoft UK

unread,
Jul 8, 2021, 12:30:32 PM7/8/21
to firebird-support
Doesn't look like there is one !

Jason (PN)

unread,
Jul 8, 2021, 12:42:56 PM7/8/21
to firebird...@googlegroups.com

Hi,

 

I also note that if you create an application level inspection handler (Search for TApplication.OnException I think), you can then inspect the actual exception object raised.

 

If e is EFDDBEngineException then

  EFDDBEngineException(e).FDObName…..

 

Looks like they have anticipated this and made it pretty easy to add code in one place.

 

 

Jason Chapman

JAC2 Consultancy Limited

Mob: 07966211959

ukDevGroup organiser – UK Based Delphi and a hundred other things all wrapped up in a friendly monthly meeting www.ukdevgroup.co.uk

Midsoft UK

unread,
Jul 9, 2021, 3:15:14 AM7/9/21
to firebird-support
Well found :) I had to remove the field to force the error.

 except
  on E: EFDDBEngineException do
   begin
     //showmessage(E.Message + ' dmData.FDQPopHead.Open');
     showmessage(E.Message + '  '+E.FDObjName) ;

   end;
 end;

[Window Title]
Servtrak

[Content]
[FireDAC][Phys][FB]Dynamic SQL Error
SQL error code = -206
Column unknown
JOBNO
At line 2, column 7  dmData.FDQPopHead

[OK]


Ariel Álvarez

unread,
Jul 9, 2021, 9:46:21 AM7/9/21
to firebird...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages