Advertisement
Guest User

EXO BD

a guest
Mar 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.79 KB | None | 0 0
  1. --EXERCICE 4--
  2. ACCEPT Var1 PROMPT 'Entre un code de matière' ;
  3. SET SERVEROUTPUT ON ;
  4. DECLARE
  5.     CURSOR modules IS
  6.         (SELECT Libelle
  7.           FROM MODULE
  8.           CONNECT BY PRIOR Codepere = Code
  9.           START WITH Code = '&Var1');
  10. Var2 VARCHAR(500);
  11. BEGIN
  12.     FOR VarCur IN modules LOOP
  13.         Var2:= Var2 || VarCur.Libelle || '/';
  14.     END LOOP;
  15.     DBMS_OUTPUT.PUT_LINE (Var2);
  16. END;
  17.  
  18. --EXERCICE 5--
  19.  
  20. ACCEPT NomTable PROMPT 'Entre le nom de la table';
  21. DECLARE
  22.     CURSOR attributs IS
  23.         (SELECT Column_Name
  24.           FROM User_Tab_Columns
  25.           WHERE TABLE_NAME  = '&NomTable');
  26. Attributs VARCHAR2 (10000);
  27. BEGIN
  28. Attributs := '&NomTable'  ||  '(';
  29.     FOR Var3  IN attributs LOOP
  30.         Attributs:= Attributs || Var3.Column_Name || ',';
  31.     END LOOP;
  32.     Attributs := Attributs || ')';
  33.     DBMS_OUTPUT.PUT_LINE (Attributs);
  34. END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement