存储过程 插入数据 一天的时间内的统计数量
时间:2010-05-28 来源:fome2010
create or replace procedure webtongji IS
BEGIN
BEGIN INSERT INTO t_event_webtongji
SELECT (SELECT COUNT(ID)
FROM T_EVENT T
WHERE EVENTSTATEID = 05
AND T.C_CREATETIME BETWEEN
(SELECT ((SYSDATE-1 - TO_DATE('19700101080000','YYYY-MM-DD HH24MISS')) * 24 * 60 * 60 * 1000) AS TIME
FROM DUAL) AND
(SELECT (SYSDATE -
TO_DATE('19700101080000', 'YYYYMMDDHH24MISS')) * 24 * 60 * 60 * 1000 AS TIME
FROM DUAL)),
(SELECT COUNT(ID)
FROM T_EVENT T
WHERE T.C_CREATETIME BETWEEN
(SELECT ((SYSDATE-1 - TO_DATE('19700101080000','YYYY-MM-DD HH24MISS')) * 24 * 60 * 60 * 1000) AS TIME
FROM DUAL) AND
(SELECT (SYSDATE -
TO_DATE('19700101080000', 'YYYYMMDDHH24MISS')) * 24 * 60 * 60 * 1000 AS TIME
FROM DUAL)),
(SELECT COUNT(ID) FROM T_EVENT T),
((SYSDATE - TO_DATE('19700101080000', 'YYYY-MM-DD HH24MISS')) * 24 * 60 * 60 * 1000)
FROM DUAL;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
END;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
end webtongji;
BEGIN
BEGIN INSERT INTO t_event_webtongji
SELECT (SELECT COUNT(ID)
FROM T_EVENT T
WHERE EVENTSTATEID = 05
AND T.C_CREATETIME BETWEEN
(SELECT ((SYSDATE-1 - TO_DATE('19700101080000','YYYY-MM-DD HH24MISS')) * 24 * 60 * 60 * 1000) AS TIME
FROM DUAL) AND
(SELECT (SYSDATE -
TO_DATE('19700101080000', 'YYYYMMDDHH24MISS')) * 24 * 60 * 60 * 1000 AS TIME
FROM DUAL)),
(SELECT COUNT(ID)
FROM T_EVENT T
WHERE T.C_CREATETIME BETWEEN
(SELECT ((SYSDATE-1 - TO_DATE('19700101080000','YYYY-MM-DD HH24MISS')) * 24 * 60 * 60 * 1000) AS TIME
FROM DUAL) AND
(SELECT (SYSDATE -
TO_DATE('19700101080000', 'YYYYMMDDHH24MISS')) * 24 * 60 * 60 * 1000 AS TIME
FROM DUAL)),
(SELECT COUNT(ID) FROM T_EVENT T),
((SYSDATE - TO_DATE('19700101080000', 'YYYY-MM-DD HH24MISS')) * 24 * 60 * 60 * 1000)
FROM DUAL;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
END;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
end webtongji;
相关阅读 更多 +