【发布时间】:2015-02-19 22:37:54
【问题描述】:
我想编写一个函数来返回名称作为变量传入的表的行数。这是我的代码:
create or replace function get_table_count (table_name IN varchar2)
return number
is
tbl_nm varchar(100) := table_name;
table_count number;
begin
select count(*)
into table_count
from tbl_nm;
dbms_output.put_line(table_count);
return table_count;
end;
我收到此错误:
FUNCTION GET_TABLE_COUNT compiled
Errors: check compiler log
Error(7,5): PL/SQL: SQL Statement ignored
Error(9,8): PL/SQL: ORA-00942: table or view does not exist
我知道tbl_nm 被解释为一个值而不是一个引用,我不知道如何逃避它。
【问题讨论】: