刚学ORACLE,请教一存储过程
create or replace procedure UpdateStatistics
(
oIP varchar2,
oConfig_USER varchar2,
oAgent varchar2
)
as
TempStat_ID number;
TempStatDetail_ID number;
BEGIN
/*检查用户是否注册统计器*/
Select count(STAT_ID) into TempStat_ID FROM Genius_Stat where config_user=oConfig_USER;
/*如果没有注册,那么注册*/
if TempStat_ID =0 then
insert into Genius_Stat (Stat_ID,CONFIG_USER,STAT_TOTAL,STAT_VIEWTOTAL)
values(GENIUS_STAT_SEQ.nextval,oConfig_USER,1,1);
/*注册后查询出Stat_ID*/
select Genius_stat_seq.Currval into TempStat_ID from DUAL;
end if;
Select STAT_ID into TempStat_ID FROM Genius_Stat where config_user=oConfig_USER;
/*检查用户是否访问过了*/
Select count(TempStat_ID) into TempStatDetail_ID FROM Genius_StatDetail
where StatDetail_IP=oIP and to_char(STATDETAIL_ADDTIME, 'yyyy-MM-dd ')=to_char(sysdate, 'yyyy-MM-dd ');
/*如果没有访问,那么更新统计*/
if TempStatDetail_ID=0 then
update Genius_Stat set STAT_TOTAL = STAT_TOTAL +1, STAT_VIEWTOTAL = STAT_VIEWTOTAL +1 where STAT_ID=TempStat_ID;
/*如果访问了,那么只更新访问次数,不更新唯一访客*/
else
update Genius_Stat set STAT_VIEWTOTAL = STAT_VIEWTOTAL +1 where STAT_ID=TempStat_ID;
end if;
insert into Genius_StatDetail(STATDETAIL_ID,STATDETAIL_IP,STATDETAIL_AGENT,STAT_ID) values(Genius_statdetail_seq.nextval,oIP,oAgent,TempStat_ID);
end UpdateStatistics;
大概就是注释中的意思
谢谢
------解决方案--------------------我的异常网推荐解决方案:oracle存储过程,http://www.aiyiweb.com/oracle-develop/177537.html
------解决方案--------------------帮顶
------解决方案--------------------看了下,感觉没问题啊!
难道有问题?
------解决方案--------------------错误信息放出来呀,