#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2011
    Posts
    1
    Rep Power
    0

    Anyone able to help?


    I am having a slight problem with an sql procedure im trying to create, keep getting an error saying "encountered ;, while expecting the following: if" could anyone help?

    CREATE OR REPLACE PROCEDURE CustOrders(
    iCust IN NUMBER
    )
    AS
    CurrentRow OrderCursor%ROWTYPE;
    oCompany VARCHAR2(15);

    CURSOR OrderCursor IS
    SELECT Description, Amount
    FROM Products, Orders
    WHERE iCust = Cust;
    BEGIN

    SELECT Company
    INTO oCompany
    FROM Customers
    WHERE iCust = CustNum;

    IF SQL%NOTFOUND THEN
    DBMS_OUTPUT.PUT_LINE ("Customer " || oCompany || " was not found.");

    ELSE IF SQL%FOUND THEN

    SELECT OrderNum
    FROM Orders
    WHERE CustNum = Cust;

    IF SQL%NOTFOUND THEN
    DBMS_OUTPUT.PUT_LINE(oCompany || " has no orders recorded.");
    ELSE IF SQL%FOUND THEN

    DBMS_OUTPUT.PUT_LINE("Orders For " || iCust || oCompany);
    DBMS_OUTPUT.PUT_LINE("Description Amount");
    FOR CurrentRow IN OrderCursor
    LOOP
    DBMS_OUTPUT.PUT_LINE (CurrentRow.Description || " " || CurrentRow.Amount);
    END LOOP;

    END IF;
    END IF;
    END;
    /
    SHOW ERRORS
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    844
    Rep Power
    387

    Cool


    Originally Posted by bolbi123456
    I am having a slight problem with an sql procedure im trying to create, keep getting an error saying "encountered ;, while expecting the following: if" could anyone help?
    ... Etc ...
    Try:
    Code:
    -- etc --
    
    IF SQL%NOTFOUND THEN
    DBMS_OUTPUT.PUT_LINE ("Customer " || oCompany || " was not found.");
    
    ELSIF SQL%FOUND THEN
    --^^--< Here
    -- etc --

IMN logo majestic logo threadwatch logo seochat tools logo