Oralce 表中存有一个字段,该字段存储表名,要把该表中的所有表名查询出来(即表名结果集),且执行结果集from 表名结果集:

declare
  v_ccount varchar2(100);
  --定义一个游标变量
  cursor c_job is
  --查询该表中的所有表名
    select tablename from tbname;
  c_row c_job%rowtype;
begin
  --循环待处理数据,即以上查出的结果集
  for c_row in c_job loop
    ---执行语句 from 循环的表名   并插入
    execute immediate 'select count(1)  from ' || c_row.tablename
      into v_ccount;
    insert into tb_count
      (tbname2, ccount)
    values
      (c_row.tablename, v_ccount);
    --dbms_output.put_line(v_ccount);
  end loop; --循环结束
  commit;
end;

相关文章:

  • 2021-08-25
  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
相关资源
相似解决方案