将影片添加到队列中的存储过程

时间:2014-11-08 22:37:52

标签: database oracle

我有以下代码将标题添加到客户的电影列表或队列中。请告诉我,我做错了什么/不做这件事。

CREATE OR REPLACE PROCEDURE add_movie_queue
(MEMBERID_arg IN NUMBER, 
DVDTITLE_arg IN VARCHAR2, 
DATEADDEDINQUEUE_arg IN DATE,
QUEUEPOSITION_arg IN INTEGER)

IS
next_movie INTEGER;
current_month INTEGER;


BEGIN

SELECT COUNT(*) INTO current_month FROM RENTAL
WHERE MEMBERID = MEMBERID_arg AND RENTALRETURNEDDATE IS NULL;

SELECT DVDID INTO next_movie FROM RENTALQUEUE
WHERE RENTALQUEUE.MEMBERID = MEMBERID_arg
AND DATEADDEDINQUEUE_arg = (SELECT MIN(DATEADDEDINQUEUE) FROM RENTALQUEUE
WHERE MEMBERID = MEMBERID_arg);

INSERT INTO RENTALQUEUE(MEMBERID,DVDID,DATEADDEDINQUEUE,QUEUEPOSITION)
VALUES(MEMBERID_arg,next_movie,DATEADDEDINQUEUE_arg,QUEUEPOSITION_arg);

END;

0 个答案:

没有答案