/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * Author:  stefa
 * Created: 11-ott-2020
 */
DELIMITER //
drop function if EXISTS awbVolCongrScostSup()//
drop function if EXISTS awbVolCongrScostInf()//
drop function if EXISTS awbCongruitaPeso()//
drop function if EXISTS awbCongruitaItems()//
drop function if EXISTS awbCongruitaObjs()//
drop function if EXISTS awbCongruitaPV()//
drop function if EXISTS awbCongruitaParPV()//

CREATE function awbVolCongrScostSup(value FLOAT)
RETURNS INTEGER DETERMINISTIC NO SQL
BEGIN
    DECLARE ret FLOAT;
    IF(@volCongrScostSup IS NULL) THEN
        SET ret = (SELECT `decode`.`decvalue` FROM `decode` WHERE `decode`.`decclass` = 'CONGRUITA' AND `decode`.`deckey` = 'volume.valore.scostamento.sup');
    ELSE
        SET ret = @volCongrScostSup;
    END IF;
    return CAST(ret as signed);
END//

DELIMITER ;

                , cast(((`ai`.`NetWeight` *
                  (
                         select
                                (1.0 + (`decode`.`decvalue` / 100000.0)) AS `value`
                         from
                                `decode`
                         where
                                (
                                       (
                                              `decode`.`decclass` = 'CONGRUITA'
                                       )
                                       and
                                       (
                                              `decode`.`deckey` = 'peso.valORe.scostamento.sup'
                                       )
                                )
                                limit 1
                  )
                  ) * 1000) as signed) AS `i_NetWeightSup`





create function p1() returns INTEGER DETERMINISTIC NO SQL return @p1;
drop function if EXISTS awbCongruitaPeso();
drop function if EXISTS awbCongruitaItems();
drop function if EXISTS awbCongruitaObjs();
drop function if EXISTS awbCongruitaPV();
drop function if EXISTS awbCongruitaParPV();
