postgresql7.1
insert into adv_user_map (user_id, adv_key, event_time, event_type)
values (:user_id, :adv_key, current_timestamp, 'c')
update adv_log
set click_count = click_count + 1
where adv_key = :adv_key
and entry_date = current_date
insert into adv_log
(adv_key, entry_date, click_count)
values (:adv_key,
current_date,
(select 1 from dual
where 0 = (select count (*)
from adv_log
where adv_key = :adv_key
and entry_date = current_date)))"
db_dml adv_insert $insert_sql