如何从嵌套表中获取oid?

68bkxrlz  于 2021-07-29  发布在  Java
关注(0)|答案(0)|浏览(220)

我创建了一个酒店的table,里面还有一个嵌套的table,一组房间。首先,我创建了房间类型:

CREATE OR REPLACE TYPE ROOM_TYPE AS OBJECT (
       Room_id NUMBER(30),
       RoomDiameter NUMBER(2),
       Price NUMBER(10,4)
);

然后我创建了一个集合:

CREATE OR REPLACE TYPE ROOMS_TYPE AS TABLE OF ROOM_TYPE;

然后表本身:

CREATE TABLE HOTEL(
      Hotel_id NUMBER(30) PRIMARY KEY,
      Phone    NUMBER(13),
      Rooms    ROOMS_TYPE
)NESTED TABLE Rooms STORE AS HOTEL_ROOMS;

然后我想把oid存储在一个变量中,所以我做了这样的事情-我在表中有6个房间,房间id为1到6:

Declare
    room_ref_1 REF ROOM_TYPE;
    room_ref_2 REF ROOM_TYPE;
    room_ref_3 REF ROOM_TYPE;
    room_ref_4 REF ROOM_TYPE;
    room_ref_5 REF ROOM_TYPE;
    room_ref_6 REF ROOM_TYPE;
begin
    SELECT REF(R) INTO room_ref_1 FROM HOTEL H, TABLE(H.Rooms) R WHERE R.Room_id = 1;
    SELECT REF(R) INTO room_ref_2 FROM HOTEL H, TABLE(H.Rooms) R WHERE R.Room_id = 2;
    SELECT REF(R) INTO room_ref_3 FROM HOTEL H, TABLE(H.Rooms) R WHERE R.Room_id = 3;
    SELECT REF(R) INTO room_ref_4 FROM HOTEL H, TABLE(H.Rooms) R WHERE R.Room_id = 4;
    SELECT REF(R) INTO room_ref_5 FROM HOTEL H, TABLE(H.Rooms) R WHERE R.Room_id = 5;
    SELECT REF(R) INTO room_ref_6 FROM HOTEL H, TABLE(H.Rooms) R WHERE R.Room_id = 6;
end;

最后我得到一个错误:ora-00904:“r.”“sys\u nc\u rowinfo$”:无效的标识符

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题