MySQL Forums
Forum List  »  Stored Procedures

Re: Syntax Error
Posted by: Peter Brawley
Date: July 02, 2012 09:05AM

Quote

If i add the delimiter is creates the procedure with a message that says it had errors.

This compiles without error in 5.6:

delimiter go
CREATE PROCEDURE Delete_BillOfMaterialsDetail (
  IN InOrderDate DATE, 
  IN InProductCode varchar(40), 
  IN InRawMaterialProductCode varchar(40) 
) 
BEGIN 
IF EXISTS (
  SELECT * 
  FROM basf_rawmaterialplanning.BillOfMaterialsDetail 
  WHERE OrderDate = InOrderDate 
    and ProductCode = InProductCode 
    and RawMaterialProductCode = InRawMaterialProductCode
) THEN 
  DELETE FROM basf_rawmaterialplanning.BillOfMaterialsDetail 
  WHERE OrderDate = InOrderDate 
    AND ProductCode = InProductCode 
    AND RawMaterialProductCode = InRawMaterialProductCode; 
END IF; 
END; 
go
delimiter ;

Quote

I also recieve an error trying to declare a variable:
DECLARE @myvar INT;

Indeed. User variables (vars whose names begin with '@') cannot be declared. Lose the '@'.

Consider reading the manual page for CREATE STORED PROCEDURE.

Options: ReplyQuote


Subject
Views
Written By
Posted
1925
July 02, 2012 01:53AM
Re: Syntax Error
989
July 02, 2012 09:05AM
958
July 05, 2012 11:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.