SQL%NOTFOUND返回的数据类型是一个布尔值。布尔值与前一条sql语句相关。当最近的一条sql语句没有操作任何行的时候,返回true。否则返回false。
eg:
update fin_customer_subj_account t
set sum_money = sum_money + p_cur_card_balance,
deal_counts = deal_counts + 1
where custom_id = p_custom_id
and card_no = p_card_no
and app_no = p_app_no
and subject_id = p_subject_id
and deal_code = p_deal_code;
--当查询不到数据时插入该条初始数据--
if SQL%NOTFOUND then
insert into fin_customer_subj_account t
(custom_id,
card_no,
deal_code,
app_no,
subject_id,
sum_money,
deal_counts,
last_update_time)
values
(p_custom_id,
p_card_no,
p_deal_code,
p_app_no,
p_subject_id,
p_cur_card_balance,
1, --初始为1
systimestamp);
end if;