oracle8.1.6 select site_node.url(s.node_id) from site_nodes s, apm_packages a where s.object_id = a.package_id and a.package_key = 'adserver' update adv_log set display_count = display_count + 1 where adv_key = :adv_key and entry_date = trunc (sysdate) insert into adv_log (adv_key, entry_date, display_count) values (:adv_key, trunc (sysdate), (select 1 from dual where 0 = (select count (*) from adv_log where adv_key = :adv_key and entry_date = trunc (sysdate)))) insert into adv_user_map (user_id, adv_key, event_time, event_type) values (:user_id,:adv_key,sysdate,'d') select map.adv_key, track_clickthru_p, target_url from adv_group_map map, advs_todays_log log, advs where rownum=1 and group_key = :group_key and map.adv_key = advs.adv_key and map.adv_key = log.adv_key order by nvl (display_count, 0)