[firebase-br] Parametros de entrada tipo numeric(9,2)

Rafael Soares listas em racsystems.inf.br
Seg Abr 11 08:05:05 -03 2005


Bom dia,

    Estou criando uma SP onde preciso passar parametros de entrada do tipo numeric(9,2) mas o firebird entende como integer.
    Ja fiz backup / restore, apaguei / recrei a SP, mudei campos numeric para float, etc... e nada mudou.
    Segue o codigo da mesma:

CREATE PROCEDURE SPREL_MARCAP (
    PDTINI DATE,
    PDTFIM DATE,
    PFORN INTEGER,
    PLFORN CHAR(1),
    PTAB INTEGER,
    PPCT NUMERIC(9,2),
    PPFR NUMERIC(9,2),
    PPCOM NUMERIC(9,2),
    PPML NUMERIC(9,2),
    PVLRDESP NUMERIC(9,2))
RETURNS (
    CODPROD INTEGER,
    DESCPROD VARCHAR(40),
    VLRCUSTO NUMERIC(9,2),
    VLRVNDATUAL NUMERIC(9,2),
    VLRVNDIDEAL NUMERIC(9,2),
    VLRLCIDEALUNIT NUMERIC(9,2),
    MARCAP INTEGER,
    QTDEVND INTEGER,
    LCLIQPROD NUMERIC(9,2),
    RPP NUMERIC(9,2))
AS
DECLARE VARIABLE VTOTITENS INTEGER;
DECLARE VARIABLE VPERCTOT NUMERIC(9,2);
begin
    select count(1)
    from TPRODS
    where (((EFORN = :PFORN) or (:PLFORN = 'S')) and
           (STATUS = 'A'))
    into :VTOTITENS;

    if (:VTOTITENS <= 0) then exit;

    RPP = cast((:PVLRDESP / :VTOTITENS) as numeric(9,2));

    VPERCTOT = (100-:PPCT-:PPFR-:PPCOM-:PPML)/100;
    if (:VPERCTOT <= 0) then VPERCTOT = 1;

    for select CODIGO,
               DESCRICAO,
               coalesce(PCCUSTO,0),
               case :PTAB
                  when 1 then coalesce(VLRTB_01,0)
                  when 2 then coalesce(VLRTB_02,0)
                  when 3 then coalesce(VLRTB_03,0)
                  when 4 then coalesce(VLRTB_04,0)
                  when 5 then coalesce(VLRTB_05,0)
                  when 6 then coalesce(VLRTB_06,0)
                  when 7 then coalesce(VLRTB_07,0)
                  when 8 then coalesce(VLRTB_08,0)
                  when 9 then coalesce(VLRTB_09,0)
                  when 10 then coalesce(VLRTB_10,0)
                  else 0
               end,
               coalesce(PCCUSTO,0)/:VPERCTOT,
               (coalesce(PCCUSTO,0)/:VPERCTOT) * (:PPML/100)
        from TPRODS
        where (((EFORN = :PFORN) or (:PLFORN = 'S')) and
               (STATUS = 'A'))
        order by DESCRICAO, CODIGO
        into :CODPROD, :DESCPROD, :VLRCUSTO, :VLRVNDATUAL, :VLRVNDIDEAL, :VLRLCIDEALUNIT
    do
    begin
        select coalesce(sum(A.QTDE),0)
        from TORC_PEDI A
            left join TORC_PED B on A.EORC_PED=B.CODIGO
        where ((B.DTCAD between :PDTINI and :PDTFIM) and
               (A.CODPROD = :CODPROD) and
               (A.TIPO = 'V'))
        into :QTDEVND;

        if (:VLRLCIDEALUNIT <> 0) then
            MARCAP = cast((:RPP / :VLRLCIDEALUNIT) as integer);
        else
            MARCAP = 0;

        LCLIQPROD = (:QTDEVND * :VLRLCIDEALUNIT) - :RPP;

        suspend;
    end
end


[]'s
Rafael Soares



Mais detalhes sobre a lista de discussão lista