1
我試圖從一組表中選擇信息。我本來Oracle按部分名稱在一組表中選擇
SELECT table_name,
to_number(
extractvalue(
xmltype(
dbms_xmlgen.getxml('select count(*) c '|| ' from ' ||owner||'.'||table_name))
,'/ROWSET/ROW/C')) count
from all_tables
where table_name like 'PAY0%' OR table_name like 'PAY1%'
然後通過我的代碼中的所有表使用
foreach(table_name in tables){
SELECT CUST_NUMBER
FROM #table_name#
}
現在我想通過以下操作才能將二者結合起來,從每個表得到cust_number循環,但它在說「‘CUST_NUMBER’:無效的標識符」
select CUST_NUMBER
from (SELECT table_name,
to_number(
extractvalue(
xmltype(
dbms_xmlgen.getxml('select count(*) c '|| ' from ' ||owner||'.'||table_name))
,'/ROWSET/ROW/C')) count
from all_tables
where table_name like 'PAY0%' OR table_name like 'PAY1%') PayTables
我知道這個問題是第一個查詢獲取表名,而不是數據,但我不知道如何獲取數據以及沒有loopin通過他們分開。
您是否正在嘗試在PLSQL或純SQL中執行此操作? –
Plain sql。循環僅僅是僞代碼來顯示我現在正在做什麼。僅僅因爲我不知道PLSQL,也許這就是我應該使用的?重要的是我只需要一個名爲PAY01%或PAY02% –
的表的結果集是的。你肯定需要使用plsql,因爲動態sql只能通過'execute immediate'命令來實現。現在我沒有時間詳細說明答案。如果沒有人回答你,我會在今晚(當地時間)晚些時候回答你。 –