Skip navigation links

MySQL Forums :: Stored Procedures :: Problem with creating a stored procedure


Advanced Search

Re: Problem with creating a stored procedure
Posted by: Barry Galbraith ()
Date: April 21, 2012 06:03AM

Close, but no cigar.

DELIMTER, tells the mysql parsing engine when input has finished, and processing should begin.
Normally, ; is delimiter, but when you want to write SQL statements as part of a procedure to be processed later, they will need the ; delimter then, but we want it ignored now.

So, we set DELIMITER $$ (it can be anything that won't otherwise appear in the SQL you are going to write), write the SQL, and then terminate input with the temporary delimiter.
Then restore normal processing with DELIMITER ;
DELIMITER $$

CREATE PROCEDURE `sp_addChild` (
IN CID int,
IN fname varchar( 50 ) ,
IN lname varchar( 50 ) ,
IN DOB DATETIME,
IN gender varchar( 10 ) ,
IN goals varchar( 255 ) ,
IN nameMeaning varchar( 255 ) ,
IN orphaned tinyint,
IN family varchar( 255 ) ,
IN eligible tinyint,
IN notes varchar( 255 )
)
BEGIN
INSERT INTO Children(
Child_ID,
Child_Fname,
Child_lname,
Child_DOB,
Child_gender,
Child_goals,
Child_nameMeaning,
Child_orphaned,
Child_family,
Child_eligible,
Child_notes
)
VALUES (
CID
, fname
, lname
, DOB
, gender
, goals
, nameMeaning
, orphaned
, family
, eligible
, notes
);
END
$$
DELIMITER ;

Good luck,
Barry.

Options: ReplyQuote


Subject Views Written By Posted
Problem with creating a stored procedure 1102 Mike Markgraf 04/13/2012 03:08PM
Re: Problem with creating a stored procedure 585 Rick James 04/15/2012 11:43PM
Re: Problem with creating a stored procedure 560 Mike Markgraf 04/19/2012 04:20PM
Re: Problem with creating a stored procedure 581 Peter Brawley 04/19/2012 04:46PM
Re: Problem with creating a stored procedure 558 Mike Markgraf 04/19/2012 05:56PM
Re: Problem with creating a stored procedure 552 Barry Galbraith 04/19/2012 08:47PM
Re: Problem with creating a stored procedure 556 Mike Markgraf 04/19/2012 11:35PM
Re: Problem with creating a stored procedure 759 Mike Markgraf 04/19/2012 11:50PM
Re: Problem with creating a stored procedure 608 Barry Galbraith 04/21/2012 06:03AM
Re: Problem with creating a stored procedure 504 Mike Markgraf 04/21/2012 10:37AM
Re: Problem with creating a stored procedure 616 Rick James 04/21/2012 12:57PM
Re: Problem with creating a stored procedure 527 Mike Markgraf 04/21/2012 10:17PM
Re: Problem with creating a stored procedure 538 Rick James 04/22/2012 11:16PM


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.