【发布时间】:2014-08-23 10:57:09
【问题描述】:
我创建了一个示例 oracle 函数来返回表中的记录数。在这里
create or replace FUNCTION TEST_COUNT
RETURN NUMBER AS recCount NUMBER;
BEGIN
SELECT COUNT(*) INTO recCount FROM **tableName**;
return recCount;
END TEST_COUNT;
它的编译成功,但是当我在 Oracle SQL-Developr 中使用命令
SELECT * FROM TABLE (TEST_COUNT());
它给我带来了以下错误。
ORA-22905: cannot access rows from a non-nested table item
22905. 00000 - "cannot access rows from a non-nested table item"
*Cause: attempt to access rows of an item whose type is not known at
parse time or that is not of a nested table type
*Action: use CAST to cast the item to a nested table type
Error at Line: 1 Column: 22
我已关注Oracle error ORA-22905: cannot access rows from a non-nested table item,但无法找到解决方案。请建议我该怎么做?
【问题讨论】:
-
你确定它来自那个代码吗?看起来不错,除非
**tableName**很奇怪。同一个脚本中还有什么,因为那不是 19 行长?根本没有创建函数;或者它是用编译错误创建的;或者它已成功创建并且调用它时出现错误?如果是你打电话的时候,你是怎么做到的? -
@AlexPoole,该函数是正确的并且没有给出任何编译错误。将 tableName 替换为数据库中表的名称。
-
那么你什么时候收到错误 - 你怎么称呼它?脚本的第 19 行是什么?
标签: oracle stored-procedures oracle-sqldeveloper