[firebase-br] Select em Procedure

Edison - Precisa Informatica Ltda edison em precisa.inf.br
Qua Ago 26 17:48:59 -03 2009


Ola pessoal 

Estou construindo uma procedure que retorna o codigo do cliente e o valor gasto na empresa
- na Tabela de movimento o codigo do cliente e integer, e o valor gasto e decimal(15,2)

eu nao consigo retornar na procedure a soma do valor gasto ( utilizando o sum )

se eu retornar o valor sem o sum da certo,
e somando a coluna, o fb retorna o seguinte erro Arithmetic overflown

Arithmetic overflow or division by zero has occurred.
arithmetic exception, numeric overflow, or string truncation.

fonte do procedure


CREATE PROCEDURE SOL_SECA001 (
    i_chavereg integer,
    s_empresa varchar(300),
    d_dataini date,
    d_datafin date)
returns (
    id_chavereg integer,
    id_secao smallint,
    id_grupo smallint,
    id_subgrupo smallint,
    id_cliente integer,
    de_razao varchar(40),
    vl_total decimal(15,2))
as
declare variable ssql varchar(700);
BEGIN
   sSql =  '  SELECT TBLCDSITE0.IDCHAVEREG, ' ;
   sSql = sSql || '  TBLCDSITE0.IDSECAO, ';
   sSql = sSql || '  TBLCDSITE0.IDGRUPO, ';
   sSql = sSql || '  TBLCDSITE0.idsubgrupo, ';
   sSql = sSql || '  TBLMVMITE0.idCliente, ';
   sSql = sSql || '  TBLCDSCLI0.RAZAO,  ';
   sSql = sSql || '  TBLMVMITE0.VLRTOTAL  ';
   sSql = sSql || '  FROM TBLMVMITE0 LEFT JOIN TBLCDSITE0 ON TBLMVMITE0.IDITEM = TBLCDSITE0.IDITEM            ' ;
   sSql = sSql || '                  LEFT JOIN TBLCDSCLI0 ON TBLMVMITE0.IDCLIENTE = TBLCDSCLI0.IDCLIENTE      ' ;
   sSql = sSql || '  WHERE TBLMVMITE0.IDEMPRESA IN ( ' || :s_empresa || ')'                                     ;
   sSql = sSql || '       AND   TBLMVMITE0.dtvalida BETWEEN ' || '''' || :d_DataIni || '''' || ' and '          ;
   sSql = sSql || '''' || :d_DataFin || ''''                                                                    ;
   sSql = sSql || '       and TBLMVMITE0.natureza = ' || '''' || 'S' || ''''                                         ;
   sSql = sSql || '       and TBLCDSITE0.idchavereg = ' || :i_ChaveReg                                               ;

   sSql = sSql || ' ORDER BY TBLCDSITE0.IDSECAO,         '                                                           ;
   sSql = sSql || '     TBLCDSITE0.IDGRUPO,              '                                                           ;
   sSql = sSql || '     TBLCDSITE0.IDSUBGRUPO           '                                                            ;


   for execute statement
      sSql
      Into :id_ChaveReg, :id_Secao, :id_Grupo, :id_SubGrupo, :id_Cliente, :de_Razao, :vl_Total
   do
      suspend;
end^



Atenciosamente 


Edison Savaris
Desenvolvedor
edison em precisa.inf.br


Mais detalhes sobre a lista de discussão lista