Yurttas/PL/DBL/oracle/F/02/Bank/q12.sp

From ZCubes Wiki
Revision as of 23:22, 4 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="text" line start="1" enclose="div">CREATE OR REPLACE PROCEDURE q12 IS cN Depositor.Customername%TYPE; no_selection EXCEPTION; CURSOR c1 IS ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
 1CREATE OR REPLACE
 2PROCEDURE q12 IS
 3
 4  cN Depositor.Customername%TYPE;
 5  
 6  no_selection EXCEPTION;
 7
 8  CURSOR c1 IS
 9   SELECT &1
10   FROM Borrower
11   WHERE branchname = '&2';
12
13BEGIN
14
15  DBMS_OUTPUT.PUT_LINE('All customers with an account');
16  DBMS_OUTPUT.PUT_LINE('at all branches located in Brooklyn.');
17  DBMS_OUTPUT.PUT_LINE('------------');
18  DBMS_OUTPUT.PUT_LINE('CustomerName');
19  DBMS_OUTPUT.PUT_LINE('------------');
20   
21  OPEN c1;
22
23  LOOP
24    FETCH c1 INTO cN;
25
26    IF c1%ROWCOUNT = 0 THEN
27      RAISE no_selection;
28    END IF;
29
30    IF c1%FOUND THEN
31      DBMS_OUTPUT.PUT_LINE(RPAD(cN, 15,' '));
32    ELSE
33      EXIT;
34    END IF;
35  END LOOP;
36    
37  CLOSE c1;
38
39EXCEPTION
40  WHEN no_selection
41  THEN
42    DBMS_OUTPUT.PUT_LINE('There are no customers with an account at all branches in Brooklyn');
43
44END;
45/