-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram7 CURSOR.sql
More file actions
54 lines (37 loc) · 1.09 KB
/
Copy pathprogram7 CURSOR.sql
File metadata and controls
54 lines (37 loc) · 1.09 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-- Developer: <Aaron>
--
-- Program #: <Programming Assignment Number 7>
--
-- Description:
-- <Adding column using ALTER TABLE, and using CURSORS with FOR LOOPS and creating an EXCEPTION handler.>
SET SERVEROUTPUT ON
ALTER TABLE MM_MOVIE
ADD (STK_FLAG varchar2(1));
DECLARE -- Declaring CURSOR variable
CURSOR curM IS
SELECT stk_flag
FROM mm_movie
WHERE movie_value * movie_qty >= 75
FOR UPDATE;
l_stk_flag mm_movie.stk_flag%TYPE; --> Type
BEGIN
OPEN curM;
LOOP
FETCH curM INTO l_stk_flag;
EXIT WHEN curM%NOTFOUND;
UPDATE mm_movie
SET stk_flag = '*' --> Setting to.
WHERE CURRENT OF curM;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN -- EXCEPTION Handler
dbms_output.put_line('A problem has occured. Tech support will be notified.');
COMMIT;
CLOSE curM;
END;
/
-- Output
SQL> @"C:\ASSIGN SQL\program7 CURSOR.sql"
Table altered.
PL/SQL procedure successfully completed.
SQL>