|
I'm trying to create a command in Crystal. I'm using oracle 10g.
The command runs in oracle fine, what i'm trying to do is this
Truncate a table BOE.REF_CHG_REPORT
Insert records into BOE.REF_CHG_REPORT from various tables
Insert records into another table
Select records from BOE.REF_CHG_REPORT.
Is this possible. my sql statement is below. Thanks for help in advance
TRUNCATE TABLE BOE.REF_CHG_REPORT;
INSERT INTO BOE.REF_CHG_REPORT
--(application_id , ref_link , reference_name , product_family_name , ref_status_date , seq_owner , submission_due_date , ref_status)
SELECT rc.application_id ,
rc.link ,
rc.name ,
c.name ,
rc.status_date ,
f.display_name ,
c.status_date ,
rst.name
FROM BOE.ref_chg rc
INNER JOIN ods.ref_status_type rst
ON rc.status_id = rst.id
LEFT OUTER JOIN ods.sequence c
ON c.application_id = rc.application_id
LEFT OUTER JOIN ods.product_family b
ON c.product_family_id = rc.id
LEFT OUTER JOIN sec.usr f
ON TO_CHAR(f.id) = c.owner
-- INNER JOIN ODS.reference e ON e.application_id = a.id
-- INNER JOIN ods.ref_chg_report rcr ON rc.id = rcr.id
WHERE rc.status_id IN ('1247400' , '1247396' , '1247396')
AND rc.id NOT IN
(SELECT id FROM boe.ref_chg_diff
)
);
INSERT INTO BOE.REF_CHG_DIFF
SELECT ID ,
NAME ,
TYPE_ID ,
STATUS_ID ,
STATUS_DATE ,
LINK ,
CREATION_DATE ,
APPLICATION_ID ,
DT_ADDED
FROM BOE.REF_CHG; -- This should be the temp table, correct?
SELECT * FROM BOE.REF_CHG_REPORT;
|