Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Hello, looking for help

Author  Topic 

bolbi123456
Starting Member

1 Post

Posted - 2011-11-30 : 23:38:58
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


If anyone has any ideas, they would be greatly appreciated

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-11-30 : 23:55:05
SQLTeam is or Microsoft SQL Server. For Oracle try dbforums.com


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -