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

时间:2016-07-16 09:50:06

标签: mysql stored-procedures mysql-workbench

我在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

1 个答案:

答案 0 :(得分:1)

存储过程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;