1

I am running DB queries in the UFT framework. During the execution, if the data is deleted in the backend tables, then UFT will throw the error message box as like below. I want to skip the error and continue and report the error description in the xml result sheet.

Error Message:

Run Error: Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record

I am trying to add by recovery scenario by calling error function and proceed to next step. My error function is as like below:

Function RecoveryFunction1(Object, Method, Arguments, retVal)
If err.number<>"" then
   error1=err.description
   Reporter.reportevent micwarning,"Error ocurred:","","Error Details: "&error1&"
End If
End Function

I have added the above function in the function library and associated the recovery scenario in the test settings. But still error message is throwing up.

Please help me to handle the error message during run time instead of writing for each and every function 'on error resume next' statement.

Sudarshan
  • 367
  • 2
  • 8
  • 20
  • Have you tried putting the suspect code under [`On Error Resume Next`](https://stackoverflow.com/questions/2202869/what-does-the-on-error-resume-next-statement-do)? – Pankaj Jaju Dec 11 '17 at 10:15
  • No.. I dont want this add in each and every function ..that's the reason, i have not tried the code.. I want this to work with the framework which is using right now.. I tried this with recovery scenario but not working.. – Vidya Hiremath Dec 11 '17 at 10:37
  • You can't use RS to hide code issues ... RS are used when the error happens in the application. Do you expect each function to fail because of DB issues? – Pankaj Jaju Dec 11 '17 at 10:52
  • No.. If records are not there in the table then run time error will be there. Now I have checked by adding one line of code to check whether the data is there or not. This is working for me. – Vidya Hiremath Dec 11 '17 at 11:28
  • But what I am expecting as like Test Setting --> On error resume next step.. If i do this, during run time , If any error happens my test run won't stop. It will continue but report won't show the step as failed and it won't report the error in the result report sheet. I am expecting this I can handle through recovery sccenario – Vidya Hiremath Dec 11 '17 at 11:32
  • If your system throws runtime error, then RS is the way to go. On error resume next will only mask the error, you can always catch it by checking err.number and stop the resume next by using `On Error Goto 0`. – Pankaj Jaju Dec 11 '17 at 11:37
  • I am using this https://sumeetkushwah.com/2014/08/12/implementing-try-catch-functionality-in-qtpuft/ and its working fine for my framework. Its simple telling to put error generating code in child function and call it from parent function, when there is an error in child function, it will return back to parent function (With on Error resume next). In this function, you should check if the error.Number is greater than 0, if so then an error occurred in the child function, else everything worked fine. You can get the error description using Error.Description – sumeet singh kushwah Dec 11 '17 at 15:48

1 Answers1

0

You need to change the way you request the view of the database so that later modifications or deletions will not affect your query.

Take a look at the docs for the ADO Recordset. It specifies different cursor types, some of which will allow you to keep a static view of the data as it was when you ran the query, while others give live views. I'm not sure which one is best for your specific use case, so you should experiment and see which one works for you.

Failing that, you can try a move heavy-handed approach which is to begin a database transaction before you do your select, which should isolate your data processing from any external changes. However, that may be undesirable if your process takes a long time, as it may lock out other processes until you end your transaction and yield the locks on the rows you're looking at. Again, it depends on your specific database environment and the systems that interact with it.

BoffinBrain
  • 6,337
  • 6
  • 33
  • 59