在PL/SQL中无法选择count(*)

编程入门 行业动态 更新时间:2024-10-27 22:33:10
本文介绍了在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(*)

本文发布于:2023-07-22 12:38:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1187580.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:PL   SQL   count

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!