Задачка для студентов:
Есть оракел. Есть cкрипт:
connect trainer@dbname;
create table students(
login varchar2(64) unique not null,
testresult number(2) default 2 not null
);
create procedure taketest(myresult number) is begin
if myresult > 2 then
raise_application_error(
-20000,
'Обломитесь. Препод не лох'
);
elsif myresult < 0 then
raise_application_error(
-20000,
'Студент, тебя сейчас отчислят!'
);
end if;
execute immediate
'update students set testresult=' ||
to_char(myresult) ||
' where login = '''||USER||'''';
end;
/
grant select on students to public;
grant execute on taketest to public;
grant create public synonym to public;
create user STUDENT1 identifified by "Password1";
create user STUDENT2 identifified by "Password2";
create user STUDENT3 identifified by "Password3";
grant connect, resource to student1;
grant connect, resource to student2;
grant connect, resource to student3;
insert into students(loginname) values ('STUDENT1');
insert into students(loginname) values ('STUDENT2');
insert into students(loginname) values ('STUDENT3');
Задача студента - используя свой логин (Student{1|2|3}) и пароль, вписать в таблицу к преподавателю свою оценку :-)