Yurttas/PL/DBL/oracle/F/02/Movie/q06.sp

From ZCubes Wiki
Jump to navigation Jump to search
 1/*
 2REM
 3REM q06.sp
 4REM
 5REM List the movies by title, director, and 
 6REM studio that are longer than 'Amistad'
 7REM in the given Movie database.
 8REM
 9*/
10
11CREATE OR REPLACE
12PROCEDURE q06 IS   
13
14  CURSOR movie_cursor IS 
15    SELECT title, studioname, name
16    FROM MovieExec, Movie
17    WHERE producercn = cn
18      AND length > (SELECT length
19                    FROM Movie
20                    WHERE title = 'Amistad');
21
22  movie_rec movie_cursor%ROWTYPE;   
23
24BEGIN
25
26  DBMS_OUTPUT.PUT_LINE('Title' || '    ' || 'StudioName' || '    ' || 'Name');
27
28  OPEN movie_cursor;
29
30  FETCH movie_cursor INTO movie_rec;
31
32  WHILE movie_cursor%FOUND
33  LOOP
34    DBMS_OUTPUT.PUT_LINE(movie_rec.title || '     ' ||
35                         movie_rec.studioname || '     ' ||
36                         movie_rec.name);
37    FETCH movie_cursor INTO movie_rec;
38  END LOOP;
39
40END q06;
41/