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!

cannot access rows from a non-nested table item

user10085094Oct 23 2014 — edited Oct 27 2014

What am I missing?!? I am running Oracle 12c(12.1.0.1.0)

 

CREATE TYPE dim_O AS OBJECT (

    dimension_id    number,

    label_en        varchar2(300)

);

CREATE TYPE dim_T AS TABLE OF dim_O;

DECLARE

    dims_t              dim_T;

BEGIN

    SELECT  CAST(MULTISET(

                    SELECT  DIMENSION_ID, LABEL_EN

                    FROM    DIMENSIONTABLE    --  actual physical table in oracle

                    WHERE   DIMENSION_ID IN (3001,3002,3003)

                    ) AS dim_T) "dim_rec"

    INTO    dims_t

    FROM    DUAL;   

    FOR i IN dims_t.FIRST..dims_t.LAST LOOP

        DBMS_OUTPUT.PUT_LINE(dims_t(i).dimension_id);

    END LOOP;

--    output from above loop is

--    3001

--    3002

--    3003

--    The following statement fails : cannot access rows from a non-nested table item

    UPDATE TABLE( SELECT dimension_id FROM TABLE(dims_t) )

    SET dimension_id = 3004 WHERE dimension_id = 3003;

--    The following statement fails : cannot access rows from a non-nested table item

  UPDATE TABLE( SELECT dimension_id FROM TABLE( CAST(dims_t as dim_T) ) )

    SET dimension_id = 3004 WHERE dimension_id = 3003;


END;

I am trying to understand this very simple example, but in vain.

Can anyone tell me why I get this error?

Thanks to everyone in advance for your time.

Marc

This post has been answered by unknown-7404 on Oct 23 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 24 2014
Added on Oct 23 2014
3 comments
979 views