Hello
I'm using Oracle 9i
I'd like to make an insert and first check if the items don't already exist.
I do 2 tests.
my procedure compiles.
it works when the SELECT INTO finds sth but not in the other case.
however i'm using the SQL%NOTFOUND cursor just after each SELECT query.
using the NO_DATA_FOUND exception would not solve my problem because the exception can be (and should be) raised twice (in order to make the insertion)
and depending on the case, it's not the same code that is executed after.
thanks for your help.
Code:
select IDXACCOUNT into get_idxaccount
from cv_account a
where ... ;
if sql%notfound
then dbms_output.put_line('can''t insert : account doesn''t exist') ;
else
select broker INTO ligne
from cv_carte cb
where ... ;
if sql%notfound
then insert into cv_carte values (get_idxaccount, cb_name, cb_broker, cb_contract ) ;
DBMS_OUTPUT.put_line('carte inserted)') ;
else
DBMS_OUTPUT.put_line('carte not inserted because it already exists') ;
end if ;
end if ;