Friday, May 14, 2010

Select in Oracle vs Select in Sybase





In Oracle I came across situation where I have a select statement in SP which executes fine when data IS Found. But crash when there is data is NOT Found. So if you have any place where you need to continue with the sp even when data is not found then do the exception block in your code when you unit test.
If you don’t do this your sp will crash and it will go to the end of your exception handler block.

Example:

begin
select myfield1 into v_myfield1
from mytable1
where myfield1= value1;
exception
when no_data_found then
v_myfield1:=NULL;
end;

I think in Sybase the select query will works fine if data is not found. But in oracle world you do need to take care of it.

Hope this helps!



No comments:

Post a Comment