[firebase-br] Errror
Levy Moreira
levymoreira.ce em gmail.com
Ter Jul 20 14:11:41 -03 2010
Eu executo o seguinte sql no ibexpert e ele me traz o resultado tranquilo:
execute block
returns (CNPJ varchar(14), IE varchar(14), EMISSAO date, UF char(2), MODELO
char(2), SERIE char(3),
NUMERO varchar(6), CFOP char(4), EMITENTE char(1), VLNOTA float,
BASEICMS float, VALORICMS float,
ISENTA float, OUTRAS float, ALIQUOTA float, SITUACAO char(1))
as
declare variable VFATUR varchar(7);
declare variable VVENDA char(1);
begin
/*/* SAÍDAS */
for
select
FAT.FATUR,
FAT.VENDA,
iif(udf_len(udf_digits(CLI.CGCCC)) = 14, UDF_DIGITS(CLI.CGCCC),
UDF_DIGITS(CLI.CPFCC)),
iif(CLI.ESTCC = 'EX', 'ISENTO', UDF_DIGITS(CLI.CGFCC)),
FAT.DTEMI,
CLI.ESTCC,
case
when (NFE.PROTOCOLO is not null) then '55'
else '01'
end MODELO,
case
when (NFE.PROTOCOLO is not null) then '1'
else ' ' -- 'U'
end SERIE,
substring(FAT.NOTFI from iif(udf_len(FAT.NOTFI) <= 6, 0,
udf_len(FAT.NOTFI) - 6 ) + 1),
UDF_DIGITS(FAT.CFOP),
--'P',
iif(substring(UDF_DIGITS(FAT.CFOP) from 1 for 1) >= 5, 'P', 'T'),
FAT.VLNOT,
FAT.IMPNO,
FAT.VALIC,
FAT.CANCE,
udf_rounddec((coalesce(FAT.VALIC, 0)/ (coalesce(FAT.VALNO, 0)-
coalesce(FAT.VALDE, 0))) * 100, 2)
from IN01FAT FAT
left join IN01NFE NFE on NFE.FATUR = FAT.FATUR and NFE.VENDA = FAT.VENDA
left join IN01CLI CLI on CLI.CDCLI = FAT.CDCLI
where (FAT.EMITE = 'S') and (FAT.DTEMI between '01.04.2010' and
'18.04.2010')
and (FAT.SERIE <> 'D' OR FAT.SERIE IS NULL) and (FAT.CFOP is not null
and trim(FAT.CFOP) <> '')
and (FAT.VALNO > 0)
into VFATUR, VVENDA, CNPJ, IE, EMISSAO, UF, MODELO, SERIE, NUMERO, CFOP,
EMITENTE,
VLNOTA, BASEICMS, VALORICMS, SITUACAO, ALIQUOTA
do
begin
if (IE = '') then
IE = 'ISENTO';
suspend;
end
end
Mas quando mando ordenar por qualquer campo ele retorna o erro:
Error Message:
----------------------------------------
Arithmetic overflow or division by zero has occurred.
arithmetic exception, numeric overflow, or string truncation.
--
Levy Moreira
Mais detalhes sobre a lista de discussão lista