MySQL Forums
Forum List  »  Newbie

Re: What's wrong with this insert?
Posted by: Peter Brawley
Date: February 07, 2013 10:53PM

First, please calm down.

Now think about delimiters a little. The default SQL command terminator string is a semicolon. To enter multiple lines for a stored routine, obviously, you need a delimiter other than that to tell MySQL that you have reached the end of your stored routine. So DELIMITER ; will not work. Try something like ...

DELIMITER go

Next, what software issued "Unexpected end of input"?

Next, nothing in SQL is ever equal to NULL, not even NULL. To test whether a value is null, use IS NULL.

Next, you have no variable named le_isBot. It is p_le_isBot.

Next, note that the last END in an sproc needs a semicolon (just like every other SQL cmd).

After that, there needs to be an instance of the DELIMITER you defined.

Putting those bits together, we get ...

DROP PROCEDURE IF EXISTS asplogentry;
DELIMITER go 
CREATE PROCEDURE aspLogEntry ( 
  p_le_let_id tinyint(1), p_le_msg varchar(2000), p_le_subject varchar(250), p_le_ipAddress varchar(150), 
  p_le_host varchar(50), p_le_referrer varchar(150), p_le_UserAgent varchar(150), p_le_IsBot tinyint(1) 
) 
BEGIN 
  IF p_le_IsBot IS NULL THEN 
    set p_le_IsBot = 0; 
  END IF; 
  INSERT INTO tblLogEntry ( le_let_id, le_msg, le_subject, le_ipAddress, le_host, le_referrer, le_UserAgent, le_isBot ) 
  VALUES 
  ( p_le_let_id, p_le_msg, p_le_subject, p_le_ipAddress, p_le_host, p_le_referrer, p_le_UserAgent, p_le_isBot ); 
END;
go
DELIMITER ;

Agreed there may be egocentricity around here, somewhere.

Options: ReplyQuote


Subject
Written By
Posted
February 07, 2013 12:14PM
Re: What's wrong with this insert?
February 07, 2013 10:53PM


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.