在Mysql中不传递参数的情况下创建存储过程 [英] Creating a stored procedure without passing parameter in Mysql
问题描述
嗨朋友们,
如何在MySql中创建一个不带任何参数的存储过程。
我试过以下代码:
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
但我得到错误..
查询:CREATE PROCEDURE custdetailLoad()BEGIN SELECT * FROM custdetail end
错误代码:1064
您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在第4行附近使用正确的语法
执行时间:00:00:00:000
转移时间:00:00:00:00
总时间:00:00:00:000
请给我一个解决方案
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
推荐答案
请尝试以下代码。
Please try below code.
CREATE PROCEDURE loadGrid()
BEGIN
SELECT * FROM custdetails;
END
请使用此链接。
这是你怎么做的
This is how you do it
CREATE PROCEDURE [dbo].[loadGrid]
AS
BEGIN
SELECT * FROM custdetails
END
GO
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);
这篇关于在Mysql中不传递参数的情况下创建存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!