Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Variable inside a cursor

pedromarquesJul 16 2009 — edited Jul 17 2009
CREATE OR REPLACE TYPE BRANCH AS TABLE OF VARCHAR2(5);

create or replace function Example RETURN NUMBER AS
branches BRANCH;
cursor ex1 IS select node from TABLE_EXAMPLE1 where node IN (branches);

BEGIN
select * BULK COLLECT INTO branches
from TABLE_EXAMPLE2;
RETURN 1;
END;

This example above is very simple and i know that i could write the query directly inside de IN clause, but i just made this code to be more easy to understand.
When i compile ,the function throws an error saying that the branches variable is not from VARCHAR2 type.
My question is : How can i pass a variable (that would be a table already fullfilled) to inside the IN clause in the cursor ? The branches variable is from BRANCH type that is a VARCHAR2 table, but the compiler says that is not the expected type(he expect VARCHAR2 and i am passing BRANCH type)

if anyone could help i would be very thankful.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 14 2009
Added on Jul 16 2009
5 comments
534 views