Click here to Skip to main content
15,937,429 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi Friends,,


How to create a stored procedure in MySql which doesn't take any parameters.

I tried following code:


Create procedure loadGrid()
as
begin 
select *from custdetails
end 


but i m getting error..

Query : CREATE PROCEDURE custdetailLoad() BEGIN SELECT *FROM custdetail end
Error Code : 1064
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 '' at line 4
Execution Time : 00:00:00:000
Transfer Time : 00:00:00:000
Total Time : 00:00:00:000

please give me a solution
Posted
Updated 12-Apr-17 0:45am

Please try below code.
SQL
CREATE PROCEDURE loadGrid()
BEGIN
    SELECT * FROM custdetails;
END

Please read more about stored procedure using this LINK.
 
Share this answer
 
This is how you do it

SQL
CREATE PROCEDURE [dbo].[loadGrid]

AS
BEGIN
      SELECT * FROM custdetails

END
GO
 
Share this answer
 
DELIMITER @@
create procedure usp_sum_of_sales(
IN pro_id int )
begin
select sum(Price) from Sales where Product_id =pro_id group by Product_id ;
end

call usp_sum_of_sales (200);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900