-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathloop.sql
More file actions
37 lines (27 loc) · 791 Bytes
/
loop.sql
File metadata and controls
37 lines (27 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
SET SERVEROUTPUT ON
CREATE OR REPLACE PROCEDURE getinfo IS
cnt customer.customer_id%TYPE;
cname customer.first_name%TYPE;
cname2 customer.last_name%TYPE;
phone customer.phone_number%TYPE;
BEGIN
FOR cnt IN 3001..3008
LOOP
SELECT first_name, last_name, phone_number
INTO cname, cname2, phone
FROM customer
WHERE
customer_id = cnt;
DBMS_OUTPUT.PUT_LINE ('Record ' || cnt);
DBMS_OUTPUT.PUT_LINE ('Name: ' || cname ||' '|| cname2);
DBMS_OUTPUT.PUT_LINE ('Phone: ' || phone);
DBMS_OUTPUT.PUT_LINE ('-----------');
END LOOP;
EXCEPTION
WHEN others THEN
DBMS_OUTPUT.PUT_LINE (SQLERRM);
END;
SHOW ERRORS;
BEGIN
getinfo;
END;