本文介绍了在PL/SQL中无法选择count(*)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DECLARE
rec_count integer default 0;
str varchar(100);
BEGIN
str := 'select count(*) into ' || rec_count ||' from emp_table';
EXECUTE IMMEDIATE (str);
dbms_output.put_line(rec_count);
END;
我无法在rec_count valibale中计数.我收到了ORA-00905消息.
I cannot get count in rec_count valibale. I received ORA-00905 message.
我必须在脚本中添加这些行,因此sql语句应如下所示. 我将行程名称传递给此脚本,它将返回该表的计数.
I have to add these lines in my script so sql statment should be like this. I would pass trip name to this script and it would return count of that table.
提前谢谢.
推荐答案您必须像下面这样使用
DECLARE rec_count integer default 0; str varchar(100); BEGIN str := 'select count(*) from emp_table'; EXECUTE IMMEDIATE str into rec_count; dbms_output.put_line(rec_count); END;必须在execute immediate之后使用into子句.请在这里 docs.oracle/cd/B12037_01 /appdev.101/b10807/13_elems017.htm 了解更多信息
the into clause must be use after execute immediate. refer here docs.oracle/cd/B12037_01/appdev.101/b10807/13_elems017.htm for more information
更多推荐
在PL/SQL中无法选择count(*)
发布评论