Oracle中表格上的光标类型

时间:2009-09-01 14:36:19

标签: oracle stored-procedures cursor

我有一个表格声明:

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

我可以在Oracle中声明可以使用我的表类型的游标吗?

1 个答案:

答案 0 :(得分:3)

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;