Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE
- --Type tableType is table of varchar2(500);
- --fixed the error, so i made a custom type outside of the anonymous block.
- roomsDescr ARRAY_VALUE;
- roomsCode ARRAY_VALUE;
- rooms VARCHAR2(4000) := 'room1;01|room2;02|room3;03|room4;04';
- BEGIN
- DBMS_OUTPUT.ENABLE;
- WITH regxRooms AS (
- SELECT REGEXP_SUBSTR(rooms, '[^|]+', 1, LEVEL) AS room
- FROM dual CONNECT BY REGEXP_SUBSTR(rooms, '[^|]+', 1, LEVEL) IS NOT NULL
- )
- SELECT
- (REGEXP_SUBSTR(regxRooms.room, '[^;]+', 1, 1)) AS DESCR ,
- (REGEXP_SUBSTR(regxRooms.room, '[^;]+', 1, 2)) AS CODE
- BULK COLLECT INTO roomsDescr, roomsCode
- FROM regxRooms;
- DBMS_OUTPUT.PUT_LINE(roomsDescr.FIRST); --somehow the output line doesn't print anything?? but it says that the block was completed successfully...
- FOR idx IN roomsDescr.FIRST..roomsDescr.LAST
- LOOP
- /*Here i would insert them, each insert will have to return me the row ID.*/
- DBMS_OUTPUT.PUT_LINE(roomsDescr(idx));
- DBMS_OUTPUT.PUT_LINE(roomsCode(idx));
- --insert into rooms returning rooms.id into roomId;
- --with the roomId, i'll need to do something like i did for the rooms and cycle through a "bed" "object"
- --made the same way as the rooms one (string separated by ; and |).
- /* Example, after inserting the room and inside this LOOP.
- for bedsIdx in bedDescr.first...bedDescr.last -> insert into beds bedDescr(idx), bedCode(idx),roomId
- */
- END LOOP;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement