Problem: Run schedular to copy from one table to other [message #324425] |
Mon, 02 June 2008 07:54 |
VEDDETA
Messages: 54 Registered: May 2008
|
Member |
|
|
Check if records of table B are 1 month old. if yes then Truncate table B_SNAPSHOT and then copy data from B to SNAPSHOT_B table otherwise no need to copy.
Run a schedular after every 15 minutes.
The tables B and SNAPSHOT_B has the below structure(same for both):
PROCESS_NAME
MQ_NAME
LAST_UPD_TMS
How I can do that using Unix and Oracle 9i.Need help with example script.
|
|
|
|
|
Re: Problem: Run schedular to copy from one table to other [message #324433 is a reply to message #324427] |
Mon, 02 June 2008 08:26 |
VEDDETA
Messages: 54 Registered: May 2008
|
Member |
|
|
-- Test.sql
DECLARE
V_COUNT NUMBER;
BEGIN
SELECT NVL((CASE WHEN ( MAX(LAST_UPD_TMS) < SYSTIMESTAMP - INTERVAL '30' DAY) THEN 1 END),0)
INTO V_COUNT
FROM B;
IF V_COUNT > 0 THEN
TRUNCATE TABLE SNAPSHOTY_B;
INSERT INTO SNAPSHOT_B SELECT * FROM PROCESS_WIP;
END IF;
END;
Tried liked this way.
How can I use it as a scheduling jobs.Please do let me know if I am wrong somewhere.
[Updated on: Mon, 02 June 2008 08:42] by Moderator Report message to a moderator
|
|
|
|
Re: Problem: Run schedular to copy from one table to other [message #324435 is a reply to message #324430] |
Mon, 02 June 2008 08:32 |
VEDDETA
Messages: 54 Registered: May 2008
|
Member |
|
|
Michel Cadot wrote on Mon, 02 June 2008 08:03 | Why have you to run every 15 minutes if you are just interested in rows that are 1 month old?
Isn't an execution each day just sufficient?
Regards
Michel
|
Yes, you are correct execution each day will be sufficient.But if someone wants last 15 minutes snapshot of data then I think it will be ok.Rite? Thanks Michel for pointing it out.
My question is how I would use as a scheduling jobs? Need your help.
|
|
|
|
|
|
|
|
Re: Problem: Run schedular to copy from one table to other [message #324591 is a reply to message #324574] |
Tue, 03 June 2008 04:26 |
VEDDETA
Messages: 54 Registered: May 2008
|
Member |
|
|
I want to execute below stored procedure after every 30 minutes using DBMS_JOBS.How can I do that? How I would use DBMS_JOB.SUBMIT. I need to know the syntax.Please help!
CREATE OR REPLACE PROCEDURE MF01.TEST( V_CNT OUT NUMBER)
AS
BEGIN
SELECT NVL((CASE WHEN ( MAX(LAST_UPD_TMS) > SYSTIMESTAMP - INTERVAL '30' DAY) THEN 1 END),0) INTO V_CNT FROM B;
IF V_CNT > 0 THEN
EXECUTE IMMEDIATE 'TRUNCATE TABLE MF01.SNAPSHOT_B';
INSERT INTO SNAPSHOT_B
SELECT * FROM B WHERE LAST_UPD_TMS < SYSTIMESTAMP - INTERVAL '30' DAY;
COMMIT;
END IF;
END;
[Updated on: Tue, 03 June 2008 04:27] Report message to a moderator
|
|
|
|
|
|
|
|
|
|