[firebase-br] Ajuda com Procedure

Galvao galvao.rodrigo em gmail.com
Sex Out 20 10:21:17 -03 2006


olá, tenho a seguinte procedure:
CREATE PROCEDURE PROC_TOTAL_DESPESAS (
    codigo integer)
returns (
    total double precision)
as
declare variable totalentrada decimal(15,2);
declare variable totalsaida decimal(15,2);
begin
FOR
select sum(E.VALOR) as TOTALENTRADA, sum(S.valor) as TOTALSAIDA, 
SUM(E.valor) AS VALOR
 from tbl_gastos_motoristas_entradas E, tbl_gastos_motoristas_saidas S

 WHERE E.idgastos=S.idgastos and E.idgastos=:CODIGO
 INTO :TOTALENTRADA, :TOTALSAIDA, :TOTAL
 DO
begin
TOTAL=0;
TOTAL = TOTALENTRADA - TOTALSAIDA;
end
SUSPEND;
END;

no sistema tenho dois registros que satisfazem a condição na tabela 
tbl_gastos_motoristas_entradas (1500 e 229,80) e tres na tabela
tbl_gastos_motoristas_saidas (250, 1263,49 e 98), o resultado é  
1.966,42 e deveria ser de 118,31 como devo fazer para que ela me retorne 
o valor correto?

Att.

Rodrigo




Mais detalhes sobre a lista de discussão lista