Michał Ziober
Michał Ziober

Reputation: 38710

Cursor on table type in Oracle

I have a table declaration:

TYPE PERSON_TYPE AS OBJECT (ID NUMBER(38), NAME VARCHAR2(20));
TYPE PERSON_TYPE_TABLE AS TABLE OF PERSON_TYPE;

Can I declare cursor which will be work with my table type in Oracle?

Upvotes: 1

Views: 8180

Answers (1)

Quassnoi
Quassnoi

Reputation: 425813

DECLARE
        p PERSON_TYPE_TABLE := PERSON_TYPE_TABLE(PERSON_TYPE(1, 'test'));
        id INT;
        name VARCHAR2(100);
        CURSOR mycur
        IS
        SELECT  *
        FROM    TABLE(p);
BEGIN
        OPEN    mycur;
        FETCH   mycur
        INTO    id, name;
        CLOSE   mycur;
END;

Upvotes: 3

Related Questions