Ik weet niet zeker wat hier precies de vereiste is, maar u kunt de volgende benadering gebruiken om het aantal records uit elke tabel op te halen.
SQL> -- This is sample data
SQL> WITH SAMPLE_DATA(TNAME) AS
2 (SELECT 'CUSTOMERS' FROM DUAL UNION ALL
3 SELECT 'INTERVAL_TAB' FROM DUAL)
4 -- Your query starts from here
5 SELECT TABLE_NAME,
6 TO_NUMBER(
7 EXTRACTVALUE( XMLTYPE(
8 DBMS_XMLGEN.GETXML('select count(*) c from ' || U.TABLE_NAME)
9 ), '/ROWSET/ROW/C')) COUNT
10 FROM USER_TABLES U JOIN SAMPLE_DATA S ON S.TNAME = U.TABLE_NAME;
TABLE_NAME COUNT
--------------- ----------
CUSTOMERS 1
INTERVAL_TAB 0
SQL>
-- Bijwerken
U kunt de weergave als volgt genereren:
-- DIT SECTIE BIJGEWERKT
CREATE OR REPLACE VIEW V_CHECK_RECORDS_AUS AS
SELECT TABLE_NAME,
TO_NUMBER(
EXTRACTVALUE( XMLTYPE(
DBMS_XMLGEN.GETXML('select count(*) c from '
|| U.TABLE_NAME || ' WHERE oe_name=''BUL''')
), '/ROWSET/ROW/C')) NUM_ROWS
FROM USER_TAB_COLUMNS U JOIN GD_TABLE_ORDER S ON S.TABLE_NAME_AUS = U.TABLE_NAME
WHERE U.COLUMN_NAME = 'OE_NAME';
Op dezelfde manier kunt u andere weergaven genereren.
-- Verdere update
CREATE OR REPLACE VIEW V_CHECK_RECORDS_AUS AS
SELECT TABLE_NAME,
CASE WHEN U.COLUMN_NAME IS NOT NULL THEN TO_NUMBER(
EXTRACTVALUE( XMLTYPE(
DBMS_XMLGEN.GETXML('select count(*) c from '
|| U.TABLE_NAME || ' WHERE ' || U.COLUMN_NAME || '=''BUL''')
), '/ROWSET/ROW/C'))
ELSE 0 END NUM_ROWS
FROM GD_TABLE_ORDER S LEFT JOIN USER_TAB_COLUMNS U
ON S.TABLE_NAME_AUS = U.TABLE_NAME AND U.COLUMN_NAME = 'OE_NAME';