Forum Discussion
From your post, I'm assuming you're trying to get the SQL database queries to raise an exception on the SQL server side and then have your Delphi Script in TestComplete handle that exception, is that correct?
If so... I don't believe that's possible. Anything returned by ADO is not returned as raised exception but encapsulated in the ADO objects. You'll need to retrieve any error codes, conditions, etc., from your result set and then use that information to raise an exception within your delphi script code.
Hello, Robert,
Thanks for your response. :smileyhappy:
I'm not sending a query to the database expecting a set.
Imagine that Delphiscript is sending an SQL statement as a "Restore Database TC from Database_Snapshot" or an "insert". Assuming that in 1st case the path to the backup file to be restored is not available at that time and the 2nd "insert" is prevented by integrity constraint.
The delphiscript would only wait for the completion of the execution of the SQL statement that was sent, if execution is prevented for some reason. Should this reason not be raised as an exception?
If this is not how it works, how will I know if it has failed or not?
Thank you. :smileyvery-happy:
- tristaanogre6 years agoEsteemed Contributor
Well, result set was just an example. I don't know, off hand, the specifics of every SQL command that can be executed via ADO. But the principle that I mentioned is still the same: exceptions raised in the SQL will not re-raise as exceptions in your DelphiScript. So, yes, on the SQL server side, it would raise as an exception if your SQL is coded to do so. But the ADO COmmand object "handles" that exception so that it is not reraised. In order for you to determine success/failure of the SQL you'll need to either examine whatever results you DO get back (could be numeric error code, status code, etc) OR, run a subsquent query to determine the state of the database after the command to see if it completed successfully.
I could be wrong in this, but that's been my experience.
- jhonathanramos6 years agoOccasional Contributor
Hi, Robert.
I understand that you said.
But, why it works different when my syntax is incorrect? In this case the exception is raised.
- tristaanogre6 years agoEsteemed Contributor
Because in that case, it's not the SQL server that's raising the exception but your utilization of the ADO objects.
Related Content
Recent Discussions
- 15 minutes agosimonaferrara
- 10 hours agoSubhraDas
- 2 days agotramuntana