Capitolul II Structurarea bazelor de date
Capitolul II Structurarea bazelor de date
Capitolul II Structurarea bazelor de date
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
47<br />
InstrucŃiuni<br />
SecvenŃele <strong>de</strong> cod scrise în PL/SQL pot conŃine comenzi SQL (CREATE,<br />
INSERT, DELETE, DROP sau ALTER).<br />
Exemplu:<br />
Insert into <strong>de</strong>ponent values (124, 'Ionescu Valer', 'Str. Crinilor Nr. 7, Craiova',<br />
'0743123989');<br />
Pe lângă comenzile SQL sau atribuirile <strong>de</strong> valori limbajul PL/SQL dispune<br />
<strong>de</strong> un set complet <strong>de</strong> instrucŃiuni necesare controlului execuŃiei programului, ca<br />
oricare limbaj procedural.<br />
InstrucŃiunea <strong>de</strong> <strong>de</strong>ci<strong>de</strong>re - IF<br />
În limbajul PL/SQL instrucŃiunea IF poate prezenta trei forme.<br />
a. IF-THEN<br />
Exemplu:<br />
BEGIN<br />
END;<br />
/<br />
-- Declaratii <strong>de</strong> variabile<br />
vanzari NUMBER(8,2) := 10100;<br />
cota NUMBER(8,2) := 10000;<br />
bonus NUMBER(6,2);<br />
ang_id NUMBER(6) := 120;<br />
IF vanzari > (cota + 200) THEN<br />
END IF;<br />
bonus := (vanzari - cota)/4;<br />
UPDATE angajati SET salar = salar + bonus WHERE<br />
angajat_id = ang_id;<br />
Astfel scris IF serveşte la condiŃionarea unei acŃiuni. AcŃiunea este<br />
<strong>de</strong>clanşată dacă expresia logică are valoarea a<strong>de</strong>vărat. SecvenŃa <strong>de</strong> cod care<br />
<strong>de</strong>scrie acŃiunea este plasată între THEN şi END IF.