This significantly improves productivity (by tens of percent on average) for queries that cannot be resolved by simply searching for one index, for example. table. However, it may hide the data / application error.
Lets have a table:
create table t (id number(10,0), padding varchar2(1000));
- intentionally not use a PC to make the example as simple as possible. The strip is used to simulate a real data load in each record.
with many entries:
insert into t (id, padding)
select rownum, rpad(' ', 1000) from dual connect by level < 10000
Now, if you ask something like
select 1 into ll_exists
from t where id = 5;
, (, , , ) . , , . , ... rownum = 1, , , , ( ) .
, rownum , .
select id into ll_id
from t where mod (id, 2) = 1
and rownum = 1;
DB 1, 3, 123... , . ( rownum TOO_MANY_ROWS. , )
, , .
begin
select 'It does'
into ls_exists
from dual where
exists (your_original_query_without_rownum);
do_something_when_it_does_exist
exception
when no_data_found then
do_something_when_it_doesn't_exist
end;