日期:2014-05-17 浏览次数:21142 次
create or replace procedure MY_TEST_1(P_TABLE_CALC IN VARCHAR2,
P_TABLE_RESULT IN VARCHAR2,
P_APPKEY IN VARCHAR2,
P_CALC_DEC IN VARCHAR2,
P_CALC_DATE IN VARCHAR2) IS
V_SQL VARCHAR2(500);
V_DATE VARCHAR2(30);
BEGIN
V_DATE := to_date(P_CALC_DATE,'yyyy-mm-dd HH24:MI:SS');
V_SQL := ' INSERT INTO ' || P_TABLE_CALC || ' (CTIME,
APPKEY,
GAMECHANNEL,
GAMEREALM,
GAMEVERSION,
RESULT_CNT,
RESULT_DEC)
SELECT ''' || to_date( P_CALC_DATE ,'yyyy-mm-dd HH24:MI:SS') || ''',
''' || P_APPKEY || ''',
GAMECHANNEL,
GAMEREALM,
GAMEVERSION,
NVL(SUM(AMOUNT), 0),''' || P_CALC_DEC || ''' FROM ' ||
P_TABLE_RESULT || ' T
WHERE T.CTIME >= ''' || to_date( P_CALC_DATE ,'yyyy-mm-dd HH24:MI:SS') || '''
GROUP BY T.GAMECHANNEL, T.GAMEVERSION, T.GAMEREALM';
EXECUTE IMMEDIATE 'COMMIT';
DBMS_OUTPUT.put_line('The result is ' || V_SQL);
DBMS_OUTPUT.put_line('The date is ' || V_DATE);
COMMIT;
END MY_TEST_1;
The result is INSERT INTO mbi_Test_calc_tmp (CTIME,
APPKEY,
GAMECHANNEL,
GAMEREALM,
GAMEVERSION,
RESULT_CNT,
RESULT_DEC)
SELECT '16-9月 -13',
'dddd'