gpt4 book ai didi

mysql - 在查询浏览器中调用 mysql 存储过程时显示错误

转载 作者:行者123 更新时间:2023-11-29 11:24:50 25 4
gpt4 key购买 nike

我在mysql中创建了一个存储过程。当我在 mysql 查询浏览器中调用该过程时,它显示错误“过程不存在”,但我确信存储过程存在于数据库中。我不知道哪里出错了。请帮助任何人

这是我的存储过程代码

DELIMITER $$

DROP PROCEDURE IF EXISTS `aad_adr`.` MonthlySalesReport(IN fromdate DATE,IN todate DATE)` $$
CREATE PROCEDURE `aad_adr`.` MonthlySalesReport(IN fromdate DATE,IN todate DATE)` ()
BEGIN
Declare fd DATE;
Declare ed DATE;
SET fd=fromdate;
SET ed=todate;
WHILE DATE(fd)<=DATE(ed)DO
select bill_master.bill_no,DATE_FORMAT(bill_master.bill_date, '%y/%m/%d') AS 'formatted_date',transaction.product_id,transaction.tax_amount,transaction.amount,transaction.amount-transaction.tax_amount as 'without_tax ',product_master.Product_name,product_master.vat from bill_master inner join transaction on bill_master.bill_no=transaction.bill_no inner join product_master on transaction.product_id=product_master.product_id where vat='14.50' and bill_master.bill_date=fd;
SET fd=DATE_ADD(fd,INTERVAL 1 DAY);
END WHILE;
END $$

DELIMITER;

调用语句:

CALL MonthlySalesReport('2016-03-06','2016-03-07');

错误:

PROCEDURE aad_adr.MonthlySalesReport does not exist

最佳答案

存储过程create和drop语句有一些问题,它的名称之前有一些空格。删除空格并运行命令 aad_adr。`

MonthlySalesReport(IN fromdate DATE, IN todate DATE)

检查以下代码中删除的空间。

DELIMITER $$

DROP PROCEDURE IF EXISTS `aad_adr`.`MonthlySalesReport` $$
CREATE PROCEDURE `aad_adr`.`MonthlySalesReport`(IN fromdate DATE,IN todate DATE)
BEGIN
Declare fd DATE;
Declare ed DATE;
SET fd=fromdate;
SET ed=todate;
WHILE DATE(fd)<=DATE(ed)DO
select bill_master.bill_no,DATE_FORMAT(bill_master.bill_date, '%y/%m/%d') AS 'formatted_date',transaction.product_id,transaction.tax_amount,transaction.amount,transaction.amount-transaction.tax_amount as 'without_tax ',product_master.Product_name,product_master.vat from bill_master inner join transaction on bill_master.bill_no=transaction.bill_no inner join product_master on transaction.product_id=product_master.product_id where vat='14.50' and bill_master.bill_date=fd;
SET fd=DATE_ADD(fd,INTERVAL 1 DAY);
END WHILE;
END $$
DELIMITER;

关于mysql - 在查询浏览器中调用 mysql 存储过程时显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38409860/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com