sql - Fastest way to check if row exist -
sql - Fastest way to check if row exist -
before select v_something, know if query returns row.
here methods, cost 2 select if row exists :
select count(1) isrowexists person condition='something'; if (isrowexists > 0) select name v_name person condition='something'; else raise name_not_found; end if; select count(1) isrowexists auto condition='something'; if (isrowexists > 0) select model v_model auto condition='something'; else raise model_not_found; end if; or :
select name v_name person condition='something'; select model v_model auto condition='something'; exception when no_data_found --do_something but method, don't know if problem came person or car...
is there other solution ? sending parameter exception ?
you do:
begin begin select name v_name person condition='something'; exception when no_data_found --do_something end; begin select model v_model auto condition='something'; exception when no_data_found --do_something end; end; / sql oracle plsql
Comments
Post a Comment