Tutorials : simple PL\SQL oracle ( exemple de quelques requetes oracle )

Tutorials : simple PL\SQL oracle ( exemple de quelques requetes oracle )

BEGIN
INSERT INTO emp(empno, ename) VALUES (1111,’Deleglise’);
COMMIT;
CREATE TABLE test (n INTEGER);
END;

———————

DECLARE
salaire emp.SAL%TYPE;
nom emp.ename%TYPE;
BEGIN
SELECT ename, sal INTO nom,salaire FROM EMP
WHERE empno=7902;
END;

———————

DECLARE
salaire emp.SAL%TYPE;
nom emp.ename%TYPE;

PROCEDURE lit_emp ( no IN INTEGER)
IS
BEGIN
SELECT ename, sal INTO nom,salaire FROM EMP
WHERE empno = no;
END lit_emp;

BEGIN
lit_emp(7902);
DBMS_OUTPUT.PUT_LINE(‘nom : ‘||nom|| ‘ salaire : ‘ || salaire);
END;

 

——————

 

DECLARE
nom emp.ename%TYPE;
salaire emp.sal%TYPE;
CURSOR C1 IS SELECT ename, NVL(sal,0) FROM emp;
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO nom, salaire;
EXIT WHEN C1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE ( nom||’ gagne ‘||salaire || ‘ dollars’);
END LOOP;
CLOSE C1;
END;

Leave a Reply