我有一个perl脚本,其中我们在2个地方使用sql查询。
第一个查询产生表名。它给出了大约100个表的名称。 那么我们将应用循环,并将表名一个接一个地传递给另一个基于表名提供数据的查询。
反正有同时加入这两个查询吗?
(select table_owner ||'.' ||table_name as table_name from ALL_TAB_MODIFICATIONS where TIMESTAMP >= sysdate -80 and table_owner in ('AXIOM_DATA','AXIOM_DATA2','AXIOM_META','AXIOM_META2') and table_name like 'RPTD_%')
MINUS
(select owner || '. ' ||object_name as table_name from dba_objects where created >= sysdate -80 and owner in ('AXIOM_DATA','AXIOM_DATA2','AXIOM_META','AXIOM_META2') and object_name like 'RPTD_%' and object_type = 'TABLE');
上面的查询给出了大约100个表名。然后
SELECT AS_OF_DATE, AS_OF_DATE, SHEET_NAME, SHEET_NUMBER, ROW_NUMBER, COL_NUMBER, CELL_NAME, CELL_VARCHAR_VALUE, CELL_FLOAT_VALUE, CELL_DATE_VALUE, DATA_TYPE, to_char(to_timestamp(to_char(AS_OF_DATE,'DD-MON-YY HH24.MI.SS'),'DD-MON-YY HH24.MI.SS'),'DD-MON-YY HH24.MI.SS') AS AS_OF_TMPSTMP
FROM $table_name WHERE AS_OF_DATE IN (
(SELECT AS_OF_DATE FROM $table_name WHERE CELL_NAME ='CONFIRM_ADJ' AND UPPER(CELL_VARCHAR_VALUE)='Y'
AND AS_OF_DATE IN (SELECT AS_OF_DATE FROM $table_name WHERE LOWER(CELL_VARCHAR_VALUE) LIKE '%focus%report%' AND to_char(AS_OF_DATE, 'YYYYMM')= '201806')));
此查询根据每个表给出输出。为此,我们使用循环并一张一张地传递表。 无论如何都可以将两个表都加入。