存储过程无结果

时间:2019-06-27 11:02:20

标签: mysql stored-procedures

这是使用存储过程时的查询,但没有结果。但是当我单独使用过程中的查询时。它有结果。 我希望此存储过程避免长查询字符串,然后将其传输到我的datagridview。我已经搜索了很多有关带有参数的存储过程的信息,这就是我如何构建此查询。

CALL BillingStorageParticulars(
1, '2019-06-16', '2019-06-30',
@entryid,
@contrno,
@type_code,
@evnt_in,
@evnt_out,
@freetime,
@storage_rate,
@lolo_rate,
@cleaning,
@rate_id,
@rate_validity,
@rendered_days
);

SELECT
@entryid AS entryid,
@contrno AS contrno,
@type_code AS type_code,
@evnt_in AS evnt_in,
@evnt_out AS evnt_out,
@freetime AS freetime,
@storage_rate AS rate,
@lolo_rate AS lolo,
@cleaning AS cleaning,
@rate_id AS rateid,
@rate_validity AS validity,
@rendered_days AS rendered;

这是我的程序

USE `ems_2019`;
DROP procedure IF EXISTS `BillingStorageParticulars`;

DELIMITER $$
USE `ems_2019`$$
CREATE DEFINER=`ems2019`@`%` PROCEDURE `BillingStorageParticulars`(
IN  clientid            INT(5),
IN  date_start          DATE,
IN  date_end            DATE,
OUT entryid             INT,
OUT contrno             TEXT(100),
OUT type_code           TEXT(50),
OUT evnt_in             DATE,
OUT evnt_out            DATE,
OUT freetime            INT,
OUT storage_rate        DECIMAL(6,2),
OUT lolo_rate           DECIMAL(6,2),
OUT cleaning            DECIMAL(6,2),
OUT rate_id             INT(7) zerofill,
OUT rate_validity       DATE,
OUT rendered_days       INT
)
BEGIN

SELECT entry_id as entry_id, cd.contr_no, cd.contrtype_code, evnt_in, evnt_out, 
        rate.days_freetime, rate.storage_rate, rate.lolo_rate, rate.sweeping + rate.waterwash + rate.chemicalwash as cleaning_rate, rate.rate_id, rate.validity,
        DATEDIFF(IF(evnt_out='0000-00-00 00:00:00', NOW(),evnt_out),evnt_in) + 1 as rendered_days

INTO    entryid,
        contrno,
        type_code,
        evnt_in,
        evnt_out,
        freetime,
        storage_rate,
        lolo_rate,
        cleaning,
        rate_id,
        rate_validity,
        rendered_days

FROM entry_list e_l

INNER JOIN (
    SELECT contr_id, contr_no, c.client_id,ct.contrtype_id, ct.contrtype_code, ct.contrtype_size
    FROM contr_list cl
    INNER JOIN client_profile c on c.client_id = cl.client_id
    INNER JOIN contr_type ct on ct.contrtype_id = cl.contype_id
    WHERE c.client_id = clientid
) cd on cd.contr_id = e_l.container_id

INNER JOIN (
    SELECT rate_id,storage_rate,lolo_rate,days_freetime,sweeping,waterwash,chemicalwash,contr_type_id,validity FROM storage_service_rates where rate_stat = 1 AND client_id = 1
) rate on rate.contr_type_id = cd.contrtype_id

WHERE evnt_in between date_start AND date_end OR evnt_out between date_start AND date_end
OR evnt_out = '0000-00-00 00:00:00';


END$$

DELIMITER ;

0 个答案:

没有答案