Lab 4
Lab 4
--1
create table tema_casa (
id number(4) primary key,
enunt varchar2(200) not null,
id_curs number(4),
deadline date,
punctaj number(4, 2),
foreign key(id_curs) references curs(id));
--Var 1
-- din conexiunea lui sys sau a lui elearn_app_admin2:
grant select on elearn_app_admin2.tema_casa to elearn_profesor11;
grant select on elearn_app_admin2.tema_casa to elearn_profesor12;
grant select on elearn_app_admin2.tema_casa to elearn_asistent13;
--var 2
--sys:
grant create view to elearn_app_admin2;
--app admin:
create or replace view viz_tema as select * from tema_casa;
grant select on viz_tema to elearn_profesor11;
grant select on viz_tema to elearn_profesor12;
grant select on viz_tema to elearn_asistent13;
--profesor1:
select * from elearn_app_admin2.viz_tema;
------
elearn_asistent3
update elearn_app_admin.tema_casa
set deadline = deadline + 21
where id=1;
commit;
----------------------------------
elearn_student2
--3
create table rezolva (
id_tema number(4),
id_stud number(4),
data_upload date,
nota number(4,2),
id_corector number(4),
primary key(id_tema, id_stud));
if contor1 = 0 then
dbms_output.put_line('Eroare: nu sunt respectate conditiile de notare,
studentul nu a depus tema');
else
if contor2 >= 1 then
dbms_output.put_line('Eroare: nu sunt respectate conditiile de notare, tema a
fost deja notata');
else
update rezolva
set nota=notadata, id_corector = codcorector
where id_stud=codstud and id_tema = codtema;
commit;
end if;
end if;
exception
when others then dbms_output.put_line('Eroare: ' || SQLERRM);
end;
/
-------------------------------
elearn_profesor11
update elearn_app_admin.tema_casa
set deadline = deadline + 7
where id=2;
commit;
commit;
execute elearn_app_admin2.proc_notare(1,1,1,10);
--------------------------------
--4
drop table utilizator cascade constraints;
drop table cursant;
----sys:
grant create role, grant any role to elearn_app_admin2;
grant create procedure to elearn_app_admin2;
exception
when others then
dbms_output.put_line('Eroare: ' || SQLERRM);
end;
/
-----sys: