The outer query and inner query will not share cursors because they are in different contexts - the outer query is a SQL statement while the inner query is inside a PL/SQL function. Each will be parsed separately.
To enable cursor sharing between the outer and inner queries, you can:
1. Pass the deptno value directly to the function instead of a bind variable
2. Define the function as pipelined and return ref cursor from it so the inner query becomes a subquery of the outer query.
3. Use inline views instead of a function.
So in summary, different contexts prevent cursor sharing. You need to modify the code to bring the queries in the same context.