Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 27th, 2009, 08:07 AM
Authorized User
 
Join Date: Apr 2007
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Stored Procedure in MySql

Hello Friends,

I'm creating procedures as the code below but it's raising an problem.



DELIMITER $$
DROP PROCEDURE IF EXISTS `SP_Select` $$
CREATE PROCEDURE `SP_Select` (id int)
BEGIN
Select ID from Rough where ID=id
END $$

DELIMITER ;


Here is the error i'm getting shown below

Script line: 3 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 3
 
Old February 27th, 2009, 08:56 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
Default

Hi Manoj,

You need to add the ; to the end of the select statement, as you would with normal statements. At the moment it thinks the END is part of the select.
This is why the delimiter is set to $$ while you are defining the procedure, so it doesn't accidentally read the semicolons within it to be the end of the procedure.

Hope this helps
Phil





Similar Threads
Thread Thread Starter Forum Replies Last Post
Empty result set from mysql stored procedure talz13 PHP Databases 3 December 28th, 2008 05:58 PM
Stored Procedure kk_kumar99 Beginning VB 6 1 October 30th, 2006 12:50 PM
stored procedure keyvanjan Classic ASP Basics 6 August 1st, 2006 07:42 AM
Location of Stored Procedure & Function in MySQL kasie MySQL 8 March 22nd, 2005 10:54 AM
Stored Procedure help flyin SQL Server 2000 6 July 25th, 2004 05:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.