Operate Oracle SQL developer – Adding table on Shadow System – All
Click on the New Table to create a blank table.
Fill in the table name and click the Advanced box. Use green cross to add a new column and fill the column properties. Use red cross to delete column you do not want.
When finish step 2, you will get this.
Create a new procedure.
Program a script in the procedure, the script should following the template below.
create or replace
PROCEDURE here replace by percedure name AS
ecode NUMBER;
emesg VARCHAR2(200);
BEGIN
—
—
INSERT
INTO shadow_copy_log VALUES
(
shadow_copy_log_seq.nextval,
‘SHADOWCOPY’,
‘COPYSTART’,
”,
‘SHARTSHADOWCOPY’,
‘noerror’,
sysdate,
TO_CHAR(sysdate,’YYYYMMDD:HH24:MI:SS’)
);
COMMIT;
——
INSERT
INTO shadow_copy_log VALUES
(
shadow_copy_log_seq.nextval,
‘SHADOWCOPY’,
‘here replace by table name‘,
”,
‘COPY START’,
‘noerror’,
sysdate,
TO_CHAR(sysdate, ‘YYYYMMDD:HH24:MI:SS’)
) ;
EXECUTE IMMEDIATE ‘TRUNCATE TABLE here replace by table name REUSE STORAGE’;
INSERT /*+ APPEND */
INTO here replace by table name
SELECT here replace by name of column 1, here replace by name of column 2, here replace by name of column 3, … … … here replace by name of column n
FROMhere replace by table name @FODHOSTING ;
INSERT
INTO shadow_copy_log VALUES
(
shadow_copy_log_seq.nextval,
‘SHADOWCOPY’,
‘here replace by table name‘,
”,
‘COPY ENDED’,
‘noerror’,
sysdate,
TO_CHAR(sysdate, ‘YYYYMMDD:HH24:MI:SS’)
) ;
COMMIT;
—
INSERT
INTO shadow_copy_log VALUES
(
shadow_copy_log_seq.nextval,
‘SHADOWCOPY’,
‘COPYEND’,
”,
‘ENDSHADOWCOPY’,
‘noerror’,
sysdate,
TO_CHAR(sysdate, ‘YYYYMMDD:HH24:MI:SS’)
);
COMMIT;
—
EXCEPTION
WHEN OTHERS THEN
BEGIN
ecode := SQLCODE;
emesg := SQLERRM;
INSERT
INTO shadow_copy_log VALUES
(
shadow_copy_log_seq.nextval,
‘SHADOWCOPY’,
‘COPYABORT’,
”,
‘ERROR’,
TO_CHAR(NVL(ecode, 0)) || ‘-‘ || emesg,
sysdate ,
TO_CHAR(sysdate, ‘YYYYMMDD:HH24:MI:SS’)
);
COMMIT;
END;
END;
–select * from shadow_copy_log order by timestamp desc
–truncate table shadow_copy_log
–EXEC famis_dashboard.shadow_copy;
Compile, debug and run the procedure.
In your local computer, find the check out folder of commit software, such as Versions or SVN. Open the SHADOW_COPY.SQL file in the scripts/dev/main folder of the check out folder.
Only add the following part in the appropriate location of SHADOW_COPY.SQL
—
INSERT
INTO shadow_copy_log VALUES
(
shadow_copy_log_seq.nextval,
‘SHADOWCOPY’,
‘here replace by table name‘,
”,
‘COPY START’,
‘noerror’,
sysdate,
TO_CHAR(sysdate, ‘YYYYMMDD:HH24:MI:SS’)
) ;
EXECUTE IMMEDIATE ‘TRUNCATE TABLE here replace by table name REUSE STORAGE’;
INSERT /*+ APPEND */
INTO here replace by table name
SELECT here replace by name of column 1, here replace by name of column 2, here replace by name of column 3, … … … here replace by name of column n
FROM here replace by table name @FODHOSTING ;
INSERT
INTO shadow_copy_log VALUES
(
shadow_copy_log_seq.nextval,
‘SHADOWCOPY’,
‘here replace by table name‘,
”,
‘COPY ENDED’,
‘noerror’,
sysdate,
TO_CHAR(sysdate, ‘YYYYMMDD:HH24:MI:SS’)
) ;
COMMIT;
Commit the SHADOW_COPY.SQL by your commit software such as Versions or SVN.