29.06.2013 Views

Elemente de PL/SQL [pdf] - Baze de date

Elemente de PL/SQL [pdf] - Baze de date

Elemente de PL/SQL [pdf] - Baze de date

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

EXEM<strong>PL</strong>U<br />

FUNCTION alt_tutor (cod_stud INTEGER, nou_tutor INTEGER)<br />

RETURN VARCHAR2 IS<br />

tutor_actual number;<br />

fara_tutor EXCEPTION; este_el EXCEPTION;<br />

BEGIN<br />

SELECT tutor INTO tutor_actual FROM stud<br />

WHERE matr = cod_stud;<br />

IF nou_tutor=cod_stud THEN<br />

RAISE este_el;<br />

ELSIF tutor_actual IS NULL THEN<br />

RAISE fara_tutor;<br />

ELSE<br />

UPDATE stud1 SET tutor = nou_tutor<br />

WHERE matr = cod_stud;<br />

RETURN 'Actualizat '||cod_stud;<br />

END IF;<br />

EXCEPTION<br />

WHEN NO_DATA_FOUND THEN<br />

RETURN 'Nu exista stu<strong>de</strong>ntul';<br />

WHEN fara_tutor THEN<br />

RETURN 'Nu are tutor';<br />

WHEN este_el THEN<br />

RETURN 'Nu isi poate fi tutor';<br />

END alt_tutor;<br />

F. Radulescu. Curs: <strong>Baze</strong> <strong>de</strong> <strong>date</strong> 90

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!