Select Into Raises NO_DATA_FOUND

Chuck_mtc

Member
Both yesterday and today I have been testing a stored procedure that contains some :

"Select myTb.Column Into MyVar From MyTb Where Column1 = Value1 And Column2 = Value2"
Clauses.

Two consecutive Selects (2nd is in the exception handler for the first, an effort to leave a more detailed error message) are raising the NO_DATA_FOUND error though the Where clauses are True. I paste the Selects (minus the INTO) into a separate SQL window and they each return a row.

Has anyone seen the Test script cause Selects to fail? Is there a workaround?

Thanks,

Chuck
 
More info..

Running the stored procedure from command line, it finds data in the first Select so skips the second one, getting the expected result.

Strange..
 
Yet More info ..
The first Select was failing with a search value not really matching the table. The value, if checked at this Select, had no trailing spaces but in the table it had two.
In the error handler, Test showed the same variable as having 2 trailing spaces. This is the value I was using for a stand-alone Query and it worked there but not in the Select inside the error handler.

Adding trailing spaces to the value before the first Select resulted in that Select working. Forcing that Select to fail via another value, the Select in the error handler shows the same 2 trailing spaces but now returns a Value Ok.

Root issue: incorrect value displayed by the Test Script inside the error handler. BTW, on return from the error handler the correct value (no trailing spaces) was again shown.

Problem Resolved!
 
Back
Top