SET SERVEROUTPUT ON;

BEGIN
  DBMS_OUTPUT.PUT_LINE(DBMS_DB_VERSION.VERSION || '.' || DBMS_DB_VERSION.RELEASE);
END;

-------------------------------------------------------

DROP TABLE emp;

CREATE TABLE emp
( matr NUMBER(10) NOT NULL,
  nom VARCHAR2(50) NOT NULL,
  sal number(7,2),  
  adresse VARCHAR2(96),
  dep NUMBER(10) NOT NULL,
  CONSTRAINT emp_pk PRIMARY KEY (matr)
);

INSERT INTO EMP VALUES (0,'Turing, Alan', 2446.13, 'Manchester, GB', 1);
INSERT INTO EMP VALUES (1,'Dijkstra, Edsger', 1779.88, 'Rotterdam, NL', 1);
INSERT INTO EMP VALUES (2,'Mac Lane, Saunders', 3141.16, 'Chicago, US', 2);

-------------------------------------------------------

DECLARE
  -- Declaration
  v_employe emp%ROWTYPE;
  v_nom emp.nom%TYPE;
BEGIN
  SELECT * INTO v_employe
  FROM emp
  WHERE matr = 0;
  v_nom := v_employe.nom;
  v_employe.dep := 20;
  v_employe.matr := 99;
  -- ...
  -- Insertion d'un tuple dans la base
  INSERT into emp VALUES v_employe;
END;

-------------------------------------------------------

DECLARE
  i number(2);  
BEGIN
  FOR i IN REVERSE 1..5 LOOP
    dbms_output.put_line('Nombre: ' || i);
  END LOOP;
END;

-------------------------------------------------------

DECLARE
  compteur number(3);
  i number(3);
BEGIN
  SELECT COUNT(*) INTO compteur
  FROM EMP;
  
  FOR i IN 1..compteur LOOP
    dbms_output.put_line('Nombre : EMP ' || i );
  END LOOP;
END;

-------------------------------------------------------

