Oracle 10g带参数Error的游标

时间:2014-04-25 11:52:38

标签: oracle

我无法理解为什么会收到此错误。我有表,但代码示例不能正常工作。这里的问题是什么?

DECLARE 
    CURSOR c_cust(p_city VARCHAR2) IS 
        SELECT * FROM cust WHERE cust.city=p_city;
    v_cust c_cust%ROWTYPE;  
    v_city c_cust%TYPE;
BEGIN
    v_city := 'London';
    OPEN c_cust (v_city);
    LOOP
        FETCH c_cust INTO v_cust;
        EXIT WHEN (c_cust%NOTFOUND);
        DBMS_OUTPUT.PUT_LINE (v_cust.cname || ' has ' || v_cust.rating);
    END LOOP;
    IF (c_cust%ISOPEN) THEN CLOSE c_cust;
END;
  

ORA-06550:第15行,第4栏:PLS-00103:   遇到符号";"   期待以下之一:if

     
      
  1. DECLARE
  2.   
  3. CURSOR c_cust(p_city VARCHAR2)IS
  4.   
  5. SELECT * FROM cust WHERE cust.city = p_city; **
  6.   

1 个答案:

答案 0 :(得分:1)

c_cust%ISOPEN应该在结束循环之前;

If .... then
  ....
end if;

如果你错过了结局;