1

我正在尝试为项目创建两个存储过程,但在两个表上都出现错误:

Member (MemberID, MembershipID, name, city.....)
RentalQueue (MovieID, DVDID, DateAdded)
DVD (DVID ID, Name..)
Rental(RentalID, MemberID, DVDID RequestDate,ShippedDate,ReturnDate)

二 存储过程描述和代码

1.) 为客户的出租队列添加标题的 PL/SQL sp。此过程应将客户 ID 和电影标题 ID 以及电影在队列中的位置作为 IN 参数。该过程还应确保不能添加重复的标题,您需要在代码中添加一些错误处理。

Create procedure add_to_queue (customerID number, titleID number) as
v_count number;
begin
        select count(memberid,dvdid) 
        from rentalqueue 
        where memberid=customerid and dvdid=titleid;

     if v_count = 1 then
        raise_application_error(20000, 'This film is already  in the rentalqueue for 
        this user');
     else 
          execute immediate ’insert into rentalqueue          
          values(’||customerid||’,’||titleid||’,’||sysdate||’)’;
     end if;
end;

2.) PL/SQL 存储过程,一旦请求发货,就从客户的租赁队列中删除一个标题。此过程应将客户 ID 和电影标题 ID 作为 IN 参数。

    Create procedure delete_from_queue (customerID number, titleID number) as
    v_count number;
begin
        select count(memberid,dvdid) 
        from rentalqueue 
        where memberid=customerid and dvdid=titleid;

        if v_count = 1 then
           execute immediate ’delete from rentalqueue 
           where memberid=’||customerid||’ and dvdid=’||titleid;
        else 
        raise_application_error(20000, 'This film was not in the rentalqueue for this  
        user');
       end if;
 end;

编译错误我得到两个如下。我知道前两个错误与我所做的 SELECT 语句有关,但不知道出了什么问题。

Error(4,20): PL/SQL: SQL Statement ignored
Error(4,27): PL/SQL: ORA-00909: invalid number of arguments
Error(6,41): PLS-00103: Encountered the symbol "’" when expecting one of the
    following:     ( - + case mod new not null <an identifier>    
<a double-quoted delimited-identifier> <a bind variable>    continue avg count current
 exists max min prior sql stddev    sum variance execute forall merge time timestamp 
interval    date <a string literal with character set specification>
    <a number> <a single-quoted SQL string> pipe    <an alternatively-quoted string
 literal with character set specification>    <an alternatively
4

2 回答 2

3
于 2012-09-18T16:14:55.727 回答
0
于 2012-09-18T16:32:24.937 回答