我们必须显示user_tables中所有表中的数据。我的代码是
DECLARE
name varchar2(50);
s_query varchar2(500);
cursor c_demo is select table_name from user_tables;
BEGIN
open c_demo;
loop
fetch c_demo into name;
EXIT WHEN c_demo%notfound;
select * into s_query from @name;
dbms_output.put_line(s_query);
end loop;
close c_demo;
end;
但它显示错误表缺少
答案 0 :(得分:0)
您可以像这样执行动态SQL:
1.定义var
sql_stmt VARCHAR2(200);
构建查询
sql_stmt := 'select * from '||name;
Exceute Statement:
for r in sql_stmt
loop
//perfom operation on data
end loop;