Advertisement
Guest User

First Script

a guest
Oct 2nd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 1.10 KB | None | 0 0
  1. SET SERVEROUTPUT ON;
  2.  
  3. DECLARE
  4.     x int;
  5.     CURSOR cust_cursor IS
  6.         SELECT c.LASTNAME, c.FIRSTNAME, c.EMAIL, cs.SKILLLEVEL
  7.         FROM ALLPOWDER.CUSTOMER c
  8.         JOIN ALLPOWDER.CUSTOMERSKILL cs
  9.         ON c.CUSTOMERID = cs.CUSTOMERID
  10.         WHERE cs.SKILLLEVEL > 5
  11.         AND cs.STYLE = 'Freestyle'
  12.         ORDER BY cs.SKILLLEVEL, c.LASTNAME, c.FIRSTNAME;
  13.        
  14.         cust_rec cust_cursor%ROWTYPE;
  15. BEGIN
  16.     OPEN cust_cursor;
  17.    
  18.     LOOP
  19.         FETCH cust_cursor INTO cust_rec;
  20.        
  21.         EXIT WHEN cust_cursor%NOTFOUND;
  22.        
  23.             DBMS_OUTPUT.PUT_LINE('Name: ' || cust_rec.lastname || ', ' || cust_rec.firstname);
  24.             DBMS_OUTPUT.PUT_LINE('Email: ' || cust_rec.email);
  25.             DBMS_OUTPUT.PUT('Half-Pipe Rating: ');
  26.              
  27.             x := 0;
  28.             LOOP
  29.                 DBMS_OUTPUT.PUT('*');
  30.                 x := x + 1;
  31.                 EXIT WHEN x = cust_rec.skilllevel;
  32.             END LOOP;
  33.            
  34.             DBMS_OUTPUT.PUT_LINE('');
  35.             DBMS_OUTPUT.PUT_LINE('');
  36.     END LOOP;
  37.    
  38.     CLOSE cust_cursor;
  39. END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement