CURSORS [message #2214] |
Fri, 28 June 2002 03:28 |
Nitin Jain
Messages: 7 Registered: October 2001
|
Junior Member |
|
|
Hello,
For the following function created I am getting the listed error.
Errors for FUNCTION GETPARENTNODES:
LINE/COL ERROR -------------------------------------------------------
22/2 PL/SQL: Statement ignored
22/10 PLS-00382: expression is of wrong type
CREATE OR REPLACE FUNCTION getParentNodes (nodeId NUMBER) RETURN NUMBER IS
CURSOR cr_ParentNodes IS
SELECT parent_node_id
FROM t_arch
WHERE specified_in_dom = 1 AND
child_node_id = nodeId;
parentNodeId cr_ParentNodes%ROWTYPE;
BEGIN
OPEN cr_ParentNodes;
LOOP
FETCH cr_ParentNodes INTO parentNodeId;
EXIT WHEN cr_ParentNodes%NOTFOUND;
END LOOP;
CLOSE cr_ParentNodes;
RETURN parentNodeId;
END getParentNodes;
Can anyone please sort this thing out.
Regards
|
|
|
Re: CURSORS [message #2217 is a reply to message #2214] |
Fri, 28 June 2002 09:34 |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
You have defined parentNodeId as a variable based on the rowtype of the cursor, and then you are returning that variable when the expected return type of the function is number.
Instead, just define parentNodeId as:
parentNodeId t_arch.parent_node_id%type;
|
|
|