Query Problem [message #187362] |
Sat, 12 August 2006 15:54 |
qadeerahmed
Messages: 63 Registered: July 2006 Location: Pakistan
|
Member |
|
|
dECLARE
TOT_COL NUMBER(5);
TOT_ROW NUMBER(5);
COUNT_roomid rooms.room_id%type;
COUNT_SEATID SEATS.SEAT_id%type;
CURSOR R is select count(room_id) from rooms;
CURSOR S is select count(SEAT_ID) from SEATS;
BEGIN
SELECT ROOMS.TOTAL_ROWS INTO TOT_ROW FROM ROOMS;
TOT_COL:=:COLS;
OPEN R;
LOOP
FETCH R into COUNT_roomid;
EXIT WHEN R%NOTFOUND;
END LOOP;
CLOSE R;
:ROOM_ID := COUNT_roomid + 1;
OPEN S;
LOOP
FETCH S into COUNT_SEATID;
EXIT WHEN S%NOTFOUND;
END LOOP;
:SEAT_ID := COUNT_SEATID + 1;
CLOSE S;
FOR J IN 1..TOT_COL LOOP
FOR K IN 1..TOT_ROW LOOP
INSERT INTO SEATS(ROOMS_NO,COL_NO)
VALUES(J,K);
commit;
END LOOP;
END LOOP;
:SEAT_ID := COUNT_SEATID + 1;
EXCEPTION
WHEN OTHERS THEN
message(SQLERRM);
END;
The Values of J and K are not inserted in table? Can anyone tell me WHY?
Actually, I want to implement the Class Room Seating Plan. i.e let's say
in col 1, row 3 is assigned to a user whose id is 3.
That's Why i'm using nested For Loops.
Is there anyother way to generate and assign that seat no to the user of specific ID....???
Thanks In Advance
Regards
Qadeer Ahmed
|
|
|
|
|