Oracle DBMS Maze Game

create table stage1(rid varchar2(3), c1 varchar2(1), c2 varchar2(1), c3 varchar2(1), c4 varchar2(1), c5 varchar2(1), c6 varchar2(1), c7 varchar2(1), c8 varchar2(1), c9 varchar2(1), c10 varchar2(1), c11 varchar2(1), c12 varchar2(1), c13 varchar2(1), c14 varchar2(1), c15 varchar2(1), c16 varchar2(1), c17 varchar2(1), c18 varchar2(1), c19 varchar2(1), c20 varchar2(1)); insert into stage1 values('1', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w','w','w'); insert into stage1 values('2', 'w', 'p', 'w', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0','0','w'); insert into stage1 values('3', 'w', '0', 'w', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0','0','w'); insert into stage1 values('4', 'w', '0', 'w', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0','0','w'); insert into stage1 values('5', 'w', '0', 'w', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0','0','w'); insert into stage1 values('6', 'w', '0', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', '0', '0', '0', '0', '0', '0', '0','0','w'); insert into stage1 values('7', 'w', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'w', '0', '0', '0', '0', '0', '0', '0','0','w'); insert into stage1 values('8', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', '0', 'w', '0', '0', '0', '0', '0', '0', '0','0','w'); insert into stage1 values('9', 'w', '0', '0', '0', '0', '0', '0', '0', 'w', '0', 'w', '0', '0', '0', '0', '0', '0', '0','0','w'); insert into stage1 values('10', 'w', '0', '0', '0', '0', '0', '0', '0', 'w', '0', 'w', '0', '0', '0', '0', '0', '0', '0','0','w'); insert into stage1 values('11', 'w', '0', '0', '0', '0', '0', '0', '0', 'w', '0', 'w', '0', '0', '0', '0', '0', '0', '0','0','w'); insert into stage1 values('12', 'w', '0', '0', '0', '0', '0', '0', '0', 'w', '0', 'w', '0', '0', '0', '0', '0', '0', '0','0','w'); insert into stage1 values('13', 'w', '0', '0', '0', '0', '0', '0', '0', 'w', '0', 'w', '0', '0', '0', '0', '0', '0', '0','0','w'); insert into stage1 values('14', 'w', '0', '0', '0', '0', '0', '0', '0', 'w', '0', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w','w','w'); insert into stage1 values('15', 'w', '0', '0', '0', '0', '0', '0', '0', 'w', '0', '0', '0', '0', '0', '0', '0', '0', '0','0','w'); insert into stage1 values('16', 'w', '0', '0', '0', '0', '0', '0', '0', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w','0','w'); insert into stage1 values('17', 'w', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'w','0','w'); insert into stage1 values('18', 'w', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'w','0','w'); insert into stage1 values('19', 'w', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'w','g','w'); insert into stage1 values('20', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w', 'w','w','w'); create table player1 as (select * from stage1); create or replace procedure showPlayer(pno in number) is cursor rowofplayer is select * from player1; rowdata player1%rowtype; begin if pno = 1 then dbms_output.put_line('Player1'); dbms_output.put_line('-------'); dbms_output.put_line(' '); for rowdata in rowofplayer loop dbms_output.put_line(rowdata.c1||' '||rowdata.c2||' '||rowdata.c3||' '||rowdata.c4||' '||rowdata.c5||' '||rowdata.c6||' '||rowdata.c7||' '||rowdata.c8||' '||rowdata.c9||' '||rowdata.c10||' '||rowdata.c11||' '||rowdata.c12||' '||rowdata.c13||' '||rowdata.c14||' '||rowdata.c15||' '||rowdata.c16||' '||rowdata.c17||' '||rowdata.c18||' '||rowdata.c19||' '||rowdata.c20||' '); end loop; else dbms_output.put_line('Argument not equals 1'); end if; end; / create or replace procedure goLeft(a in number) is cursor rowofplayer is select * from player1 where c1 = 'p' or c2 = 'p' or c3 = 'p' or c4 = 'p' or c5 = 'p' or c6 = 'p' or c7 = 'p' or c8 = 'p' or c9 = 'p' or c10 = 'p' or c11 = 'p' or c12 = 'p' or c13 = 'p' or c14 = 'p' or c15 = 'p' or c16 = 'p' or c17 = 'p' or c18 = 'p' or c19 = 'p' or c20 = 'p'; rowdata player1%rowtype; begin for rowdata in rowofplayer loop if rowdata.c3 = 'p' and rowdata.c2 <> 'w' then update player1 set c2 = 'p', c3 = '0' where rid = rowdata.rid; elsif rowdata.c4 = 'p' and rowdata.c3 <> 'w' then update player1 set c3 = 'p', c4 = '0' where rid = rowdata.rid; elsif rowdata.c5 = 'p' and rowdata.c4 <> 'w' then update player1 set c4 = 'p', c5 = '0' where rid = rowdata.rid; elsif rowdata.c6 = 'p' and rowdata.c5 <> 'w' then update player1 set c5 = 'p', c6 = '0' where rid = rowdata.rid; elsif rowdata.c7 = 'p' and rowdata.c6 <> 'w' then update player1 set c6 = 'p', c7 = '0' where rid = rowdata.rid; elsif rowdata.c8 = 'p' and rowdata.c7 <> 'w' then update player1 set c7 = 'p', c8 = '0' where rid = rowdata.rid; elsif rowdata.c9 = 'p' and rowdata.c8 <> 'w' then update player1 set c8 = 'p', c9 = '0' where rid = rowdata.rid; elsif rowdata.c10 = 'p' and rowdata.c9 <> 'w' then update player1 set c9 = 'p', c10 = '0' where rid = rowdata.rid; elsif rowdata.c11 = 'p' and rowdata.c10 <> 'w' then update player1 set c10 = 'p', c11 = '0' where rid = rowdata.rid; elsif rowdata.c12 = 'p' and rowdata.c11 <> 'w' then update player1 set c11 = 'p', c12 = '0' where rid = rowdata.rid; elsif rowdata.c13 = 'p' and rowdata.c12 <> 'w' then update player1 set c12 = 'p', c13 = '0' where rid = rowdata.rid; elsif rowdata.c14 = 'p' and rowdata.c13 <> 'w' then update player1 set c13 = 'p', c14 = '0' where rid = rowdata.rid; elsif rowdata.c15 = 'p' and rowdata.c14 <> 'w' then update player1 set c14 = 'p', c15 = '0' where rid = rowdata.rid; elsif rowdata.c16 = 'p' and rowdata.c15 <> 'w' then update player1 set c15 = 'p', c16 = '0' where rid = rowdata.rid; elsif rowdata.c17 = 'p' and rowdata.c16 <> 'w' then update player1 set c16 = 'p', c17 = '0' where rid = rowdata.rid; elsif rowdata.c18 = 'p' and rowdata.c17 <> 'w' then update player1 set c17 = 'p', c18 = '0' where rid = rowdata.rid; elsif rowdata.c19 = 'p' and rowdata.c18 <> 'w' then update player1 set c18 = 'p', c19 = '0' where rid = rowdata.rid; end if; end loop; showPlayer(1); end; / create or replace procedure goRight(a in number) is cursor rowofplayer is select * from player1 where c1 = 'p' or c2 = 'p' or c3 = 'p' or c4 = 'p' or c5 = 'p' or c6 = 'p' or c7 = 'p' or c8 = 'p' or c9 = 'p' or c10 = 'p' or c11 = 'p' or c12 = 'p' or c13 = 'p' or c14 = 'p' or c15 = 'p' or c16 = 'p' or c17 = 'p' or c18 = 'p' or c19 = 'p' or c20 = 'p'; rowdata player1%rowtype; begin for rowdata in rowofplayer loop if rowdata.c3 <> 'w' and rowdata.c2 = 'p' then update player1 set c2 = '0', c3 = 'p' where rid = rowdata.rid; elsif rowdata.c4 <> 'w' and rowdata.c3 = 'p' then update player1 set c3 = '0', c4 = 'p' where rid = rowdata.rid; elsif rowdata.c5 <> 'w' and rowdata.c4 = 'p' then update player1 set c4 = '0', c5 = 'p' where rid = rowdata.rid; elsif rowdata.c6 <> 'w' and rowdata.c5 = 'p' then update player1 set c5 = '0', c6 = 'p' where rid = rowdata.rid; elsif rowdata.c7 <> 'w' and rowdata.c6 = 'p' then update player1 set c6 = '0', c7 = 'p' where rid = rowdata.rid; elsif rowdata.c8 <> 'w' and rowdata.c7 = 'p' then update player1 set c7 = '0', c8 = 'p' where rid = rowdata.rid; elsif rowdata.c9 <> 'w' and rowdata.c8 = 'p' then update player1 set c8 = '0', c9 = 'p' where rid = rowdata.rid; elsif rowdata.c10 <> 'w' and rowdata.c9 = 'p' then update player1 set c9 = '0', c10 = 'p' where rid = rowdata.rid; elsif rowdata.c11 <> 'w' and rowdata.c10 = 'p' then update player1 set c10 = '0', c11 = 'p' where rid = rowdata.rid; elsif rowdata.c12 <> 'w' and rowdata.c11 = 'p' then update player1 set c11 = '0', c12 = 'p' where rid = rowdata.rid; elsif rowdata.c13 <> 'w' and rowdata.c12 = 'p' then update player1 set c12 = '0', c13 = 'p' where rid = rowdata.rid; elsif rowdata.c14 <> 'w' and rowdata.c13 = 'p' then update player1 set c13 = '0', c14 = 'p' where rid = rowdata.rid; elsif rowdata.c15 <> 'w' and rowdata.c14 = 'p' then update player1 set c14 = '0', c15 = 'p' where rid = rowdata.rid; elsif rowdata.c16 <> 'w' and rowdata.c15 = 'p' then update player1 set c15 = '0', c16 = 'p' where rid = rowdata.rid; elsif rowdata.c17 <> 'w' and rowdata.c16 = 'p' then update player1 set c16 = '0', c17 = 'p' where rid = rowdata.rid; elsif rowdata.c18 <> 'w' and rowdata.c17 = 'p' then update player1 set c17 = '0', c18 = 'p' where rid = rowdata.rid; elsif rowdata.c19 <> 'w' and rowdata.c18 = 'p' then update player1 set c18 = '0', c19 = 'p' where rid = rowdata.rid; end if; end loop; showPlayer(1); end; / create or replace procedure goUp(a in number) is cursor rowofplayer is select * from player1 where c1 = 'p' or c2 = 'p' or c3 = 'p' or c4 = 'p' or c5 = 'p' or c6 = 'p' or c7 = 'p' or c8 = 'p' or c9 = 'p' or c10 = 'p' or c11 = 'p' or c12 = 'p' or c13 = 'p' or c14 = 'p' or c15 = 'p' or c16 = 'p' or c17 = 'p' or c18 = 'p' or c19 = 'p' or c20 = 'p'; rowdata player1%rowtype; begin for rowdata in rowofplayer loop if rowdata.rid = '2' then exit; elsif rowdata.c2 = 'p' then update player1 set c2 = 'p' where rid = rowdata.rid-1; update player1 set c2 = '0' where rid = rowdata.rid; elsif rowdata.c3 = 'p' then update player1 set c3 = 'p' where rid = rowdata.rid-1; update player1 set c3 = '0' where rid = rowdata.rid; elsif rowdata.c4 = 'p' then update player1 set c4 = 'p' where rid = rowdata.rid-1; update player1 set c4 = '0' where rid = rowdata.rid; elsif rowdata.c5 = 'p' then update player1 set c5 = 'p' where rid = rowdata.rid-1; update player1 set c5 = '0' where rid = rowdata.rid; elsif rowdata.c6 = 'p' then update player1 set c6 = 'p' where rid = rowdata.rid-1; update player1 set c6 = '0' where rid = rowdata.rid; elsif rowdata.c7 = 'p' then update player1 set c7 = 'p' where rid = rowdata.rid-1; update player1 set c7 = '0' where rid = rowdata.rid; elsif rowdata.c8 = 'p' then update player1 set c8 = 'p' where rid = rowdata.rid-1; update player1 set c8 = '0' where rid = rowdata.rid; elsif rowdata.c9 = 'p' then update player1 set c9 = 'p' where rid = rowdata.rid-1; update player1 set c9 = '0' where rid = rowdata.rid; elsif rowdata.c10 = 'p' then update player1 set c10 = 'p' where rid = rowdata.rid-1; update player1 set c10 = '0' where rid = rowdata.rid; elsif rowdata.c11 = 'p' then update player1 set c11 = 'p' where rid = rowdata.rid-1; update player1 set c11 = '0' where rid = rowdata.rid; elsif rowdata.c12 = 'p' then update player1 set c12 = 'p' where rid = rowdata.rid-1; update player1 set c12 = '0' where rid = rowdata.rid; elsif rowdata.c13 = 'p' then update player1 set c13 = 'p' where rid = rowdata.rid-1; update player1 set c13 = '0' where rid = rowdata.rid; elsif rowdata.c14 = 'p' then update player1 set c14 = 'p' where rid = rowdata.rid-1; update player1 set c14 = '0' where rid = rowdata.rid; elsif rowdata.c15 = 'p' then update player1 set c15 = 'p' where rid = rowdata.rid-1; update player1 set c15 = '0' where rid = rowdata.rid; elsif rowdata.c16 = 'p' then update player1 set c16 = 'p' where rid = rowdata.rid-1; update player1 set c16 = '0' where rid = rowdata.rid; elsif rowdata.c17 = 'p' then update player1 set c17 = 'p' where rid = rowdata.rid-1; update player1 set c17 = '0' where rid = rowdata.rid; elsif rowdata.c18 = 'p' then update player1 set c18 = 'p' where rid = rowdata.rid-1; update player1 set c18 = '0' where rid = rowdata.rid; elsif rowdata.c19 = 'p' then update player1 set c19 = 'p', c20 = rowdata.c20 where rid = rowdata.rid-1; update player1 set c19 = '0', c20 = rowdata.c20 where rid = rowdata.rid; end if; end loop; showPlayer(1); end; / create or replace procedure goDown(a in number) is cursor rowofplayer is select * from player1 where c1 = 'p' or c2 = 'p' or c3 = 'p' or c4 = 'p' or c5 = 'p' or c6 = 'p' or c7 = 'p' or c8 = 'p' or c9 = 'p' or c10 = 'p' or c11 = 'p' or c12 = 'p' or c13 = 'p' or c14 = 'p' or c15 = 'p' or c16 = 'p' or c17 = 'p' or c18 = 'p' or c19 = 'p' or c20 = 'p'; rowdata player1%rowtype; begin for rowdata in rowofplayer loop if rowdata.rid = '19' then exit; elsif rowdata.c2 = 'p' then update player1 set c2 = 'p' where rid = rowdata.rid+1; update player1 set c2 = '0' where rid = rowdata.rid; elsif rowdata.c3 = 'p' then update player1 set c3 = 'p' where rid = rowdata.rid+1; update player1 set c3 = '0' where rid = rowdata.rid; elsif rowdata.c4 = 'p' then update player1 set c4 = 'p' where rid = rowdata.rid+1; update player1 set c4 = '0' where rid = rowdata.rid; elsif rowdata.c5 = 'p' then update player1 set c5 = 'p' where rid = rowdata.rid+1; update player1 set c5 = '0' where rid = rowdata.rid; elsif rowdata.c6 = 'p' then update player1 set c6 = 'p' where rid = rowdata.rid+1; update player1 set c6 = '0' where rid = rowdata.rid; elsif rowdata.c7 = 'p' then update player1 set c7 = 'p' where rid = rowdata.rid+1; update player1 set c7 = '0' where rid = rowdata.rid; elsif rowdata.c8 = 'p' then update player1 set c8 = 'p' where rid = rowdata.rid+1; update player1 set c8 = '0' where rid = rowdata.rid; elsif rowdata.c9 = 'p' then update player1 set c9 = 'p' where rid = rowdata.rid+1; update player1 set c9 = '0' where rid = rowdata.rid; elsif rowdata.c10 = 'p' then update player1 set c10 = 'p' where rid = rowdata.rid+1; update player1 set c10 = '0' where rid = rowdata.rid; elsif rowdata.c11 = 'p' then update player1 set c11 = 'p' where rid = rowdata.rid+1; update player1 set c11 = '0' where rid = rowdata.rid; elsif rowdata.c12 = 'p' then update player1 set c12 = 'p' where rid = rowdata.rid+1; update player1 set c12 = '0' where rid = rowdata.rid; elsif rowdata.c13 = 'p' then update player1 set c13 = 'p' where rid = rowdata.rid+1; update player1 set c13 = '0' where rid = rowdata.rid; elsif rowdata.c14 = 'p' then update player1 set c14 = 'p' where rid = rowdata.rid+1; update player1 set c14 = '0' where rid = rowdata.rid; elsif rowdata.c15 = 'p' then update player1 set c15 = 'p' where rid = rowdata.rid+1; update player1 set c15 = '0' where rid = rowdata.rid; elsif rowdata.c16 = 'p' then update player1 set c16 = 'p' where rid = rowdata.rid+1; update player1 set c16 = '0' where rid = rowdata.rid; elsif rowdata.c17 = 'p' then update player1 set c17 = 'p' where rid = rowdata.rid+1; update player1 set c17 = '0' where rid = rowdata.rid; elsif rowdata.c18 = 'p' then update player1 set c18 = 'p' where rid = rowdata.rid+1; update player1 set c18 = '0' where rid = rowdata.rid; elsif rowdata.c19 = 'p' then update player1 set c19 = 'p' where rid = rowdata.rid+1; update player1 set c19 = '0' where rid = rowdata.rid; end if; end loop; showPlayer(1); end; /
DBMS MCA 2nd YEAR PROJECT

You just need to execute all the statements

set serverout on;

call registerPlayer('username', 'password');
call login('username', 'passoword');
call showPlayer(1);
call goDown(1);
call goUp(1);
call goLeft(1);
call goRight(1);

call logout(1);

triggers:

updateScoreTrigger1
updateScoreTrigger2

You are p:player.
Eat a : apple / m:mango to increase score. Stage will automatically change when stamping g:goal.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.