Professional Documents
Culture Documents
--2----------------------------------
CREATE OR REPLACE PROCEDURE is_movie_expensive(
p_mov_id IN movie.movie_id%TYPE
)AS
name movie.title%TYPE;
bud movie.budget%TYPE;
BEGIN
SELECT title, budget
INTO name, bud
FROM movie
WHERE movie_id = p_mov_id;
IF bud > 50000 THEN
DBMS_OUTPUT.PUT_LINE(name || ' is an expensive movie');
ELSE
DBMS_OUTPUT.PUT_LINE(name || ' is not an expensive movie');
END IF;
END;
------
EXEC is_movie_expensive(5)
--3------------------------------
CREATE OR REPLACE PROCEDURE get_genres IS
TYPE gen_table IS TABLE OF genre.genre_name%TYPE INDEX BY BINARY_INTEGER;
gen_names gen_table;
gen_id genre.genre_id%TYPE := 1002;
BEGIN
FOR i IN 1..10 LOOP
SELECT genre_name
INTO gen_names(i)
FROM genre
WHERE genre_id = gen_id;
gen_id := gen_id + 1;
END LOOP;
FOR i IN 1..gen_names.COUNT LOOP
DBMS_OUTPUT.PUT_LINE(gen_names(i));
END LOOP;
END;
-------
EXEC get_genres;
--4-----------------------
CREATE OR REPLACE PROCEDURE get_movie_info(p_mov_id IN movie.movie_id%TYPE)
IS
TYPE movie_info IS RECORD (
mov_id movie.movie_id%TYPE,
mov_name movie.title%TYPE,
bud movie.budget%TYPE
);
v_movie movie_info;
BEGIN
SELECT movie_id, title, budget
INTO v_movie
FROM movie
WHERE movie_id = p_mov_id;
DBMS_OUTPUT.PUT_LINE('Movie ID: ' || v_movie.mov_id);
DBMS_OUTPUT.PUT_LINE('Name: ' || v_movie.mov_name);
DBMS_OUTPUT.PUT_LINE('Budget: ' || v_movie.bud);
END;
-----
EXEC get_movie_info(285);
--5-------------------------------------------
CREATE OR REPLACE PROCEDURE get_movies_filtered_by_runtime_and_release_date(p_runt
IN movie.runtime%TYPE, p_rel IN movie.release_date%TYPE)
IS
CURSOR mov_cursor IS
SELECT *
FROM movie
WHERE runtime > p_runt AND release_date > p_rel; --'27-APR-20';
mov_table movie%ROWTYPE;
BEGIN
OPEN mov_cursor;
LOOP
FETCH mov_cursor INTO mov_table;
EXIT WHEN mov_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(mov_table.title || ' release date after than ' ||
mov_table.release_date);
END LOOP;
CLOSE mov_cursor;
END;
-----
EXEC get_movies_filtered_by_runtime_and_release_date(90, '27-APR-20')
--------------------------------------------------------------------------
INSERT INTO movie (movie_id, title, budget, overview, release_date, runtime) VALUES
(5,'Avengers: Infinity War',4000000,'American superhero film based on the Marvel
Comics','27-APR-18',149);
INSERT INTO movie(movie_id, title, budget, overview, release_date, runtime)
values(1, 'Avatar 2', 50000, 'movie about blue people', '16-DEC-22', 192);
INSERT INTO movie(movie_id, title, budget, overview, release_date, runtime)
values(285, 'Pirates of the Caribbean: The Curse of the Black Pearl', 700000,
'movie about pirates', '22-AUG-03', 143);
INSERT INTO movie(movie_id, title, budget, overview, release_date, runtime)
values(100, 'Fast & Furious Presents: Hobbs & Shaw', 700000, ' American buddy
action comedy film directed by David Leitch', '02-AUG-19', 135);
INSERT INTO movie(movie_id, title, budget, overview, release_date, runtime)
values(35, 'Sherlock Holmes', 200000, 'Detective Sherlock Holmes and his stalwart
partner Watson engage in a battle of wits and brawn with a nemesis whose plot is a
threat to all of England.', '15-JUN-19', 128);
INSERT INTO movie (movie_id, title, budget, overview, release_date, runtime) VALUES
(7,'The Nun',3500000,'American gothic supernatural horror film ','20-NOV-18',95);
INSERT INTO movie(movie_id, title, budget, overview, release_date, runtime)
values(2, 'Annabelle: Creation', 704000, 'Years after the tragic death of their
little daughter, a doll- maker and his wife welcome a nun and a group of orphaned
girls to their home, but somehow they become the target of the doll-makers demonic
creation, Annabelle.', '10-AUG-17', 109);
INSERT INTO movie(movie_id, title, budget, overview, release_date, runtime)
values(207, 'Annabelle', 620000, 'movie about the evil doll', '22-AUG-13', 143);
INSERT INTO movie(movie_id, title, budget, overview, release_date, runtime)
values(26, 'The Conjuring', 390000, 'Paranormal investigators Ed and Lorraine
Warren work to help a family terrorized by a dark presence.', '05-DEC-13', 135);
INSERT INTO movie(movie_id, title, budget, overview, release_date, runtime)
values(666, 'Annabelle Comes Home', 450000, 'Determined to keep Annabelle from
wreaking more havoc, demonologists Ed and Lorraine Warren bring the possessed doll
to the locked artifacts room in their home, placing her “safely” behind sacred
glass and enlisting a priest’s holy blessing. But an unholy night of horror awaits
as Annabelle awakens the evil spirits in the room, who all set their sights on a
new target—the Warrens’ ten year- old daughter, Judy, and her friends.', '26-JUN-
19', 128);
INSERT INTO movie (movie_id, title, budget, overview, release_date, runtime) VALUES
(8,'The Guilty',350000,'Netflix','20-NOV-21',90);
INSERT INTO movie(movie_id, title, budget, overview, release_date, runtime)
values(3, 'The Deep House', 704000, 'English-language French supernatural horror
film written and directed by Julien Maury and Alexandre Bustillo.', '10-AUG-21',
90);
INSERT INTO movie(movie_id, title, budget, overview, release_date, runtime)
values(4, 'The Pale Blue Eye', 620000, 'A world-weary detective is hired to
investigate the murder of a West Point cadet. Stymied by the cadets code of
silence, he enlists one of their own to help unravel the case - a young man the
world would come to know as Edgar Allan Poe.', '22-AUG-13', 103);
INSERT INTO movie(movie_id, title, budget, overview, release_date, runtime)
values(6, 'Knives Out', 390000, 'A detective investigates the death of the
patriarch of an eccentric, combative family.', '05-DEC-13', 135);
INSERT INTO movie(movie_id, title, budget, overview, release_date, runtime)
values(9, 'Ant-Man and the Wasp: Quantumania', 450000, 'Scott Lang and Hope Van
Dyne, along with Hank Pym and Janet Van Dyne, explore the Quantum Realm, where they
interact with strange creatures and embark on an adventure that goes beyond the
limits of what they thought was possible.', '16-FEB-23', 125);
INSERT ALL
INTO gender (gender_id, gender) VALUES (0,'Unspecified')
INTO gender (gender_id, gender) VALUES (1,'Female')
INTO gender (gender_id, gender) VALUES (2,'Male')
SELECT * FROM dual;
INSERT ALL
INTO language (language_id, language_name) VALUES (2001,'English')
INTO language (language_id, language_name) VALUES (2002,'russian')
INTO language (language_id, language_name) VALUES (2003,'kazakh')
SELECT * FROM dual;
INSERT ALL
INTO country (country_id, country_name) VALUES (151,'USA')
INTO country (country_id, country_name) VALUES (152,'Great Britain')
INTO country (country_id, country_name) VALUES (153,'Kazakhstan')
INTO country (country_id, country_name) VALUES (154,'Turkey')
INTO country (country_id, country_name) VALUES (155,'India')
SELECT * FROM dual;
INSERT ALL
INTO country (country_id, country_name) VALUES (156,'Norway')
INTO country (country_id, country_name) VALUES (157,'Sweden')
INTO country (country_id, country_name) VALUES (158,'Spain')
INTO country (country_id, country_name) VALUES (159,'Australia')
INTO country (country_id, country_name) VALUES (160,'Germany')
INTO country (country_id, country_name) VALUES (161,'France')
INTO country (country_id, country_name) VALUES (162,'Egypt')
INTO country (country_id, country_name) VALUES (163,'Italy')
INTO country (country_id, country_name) VALUES (164,'South Korea')
INTO country (country_id, country_name) VALUES (165,'Brazil')
SELECT * FROM dual;