[firebase-br] Stored Procedure

Paulo Portella pportellaa.firebase em gmail.com
Qui Fev 3 15:57:39 -03 2011


Segue um exemplo simples pra vc ver se te ajuda, eu faço uso de 
DECIMALSEPARATOR


   DecimalSeparator:='.';

   sql:=' INSERT INTO CRED_LIQUIDACAO ( '+
        ' ID, '+
        ' TIPO, '+
        ' ARQUIVO, '+
        ' EMPRESA_CODIGO, '+
        ' RESERVADO, '+
        ' DATA_COMPRA, '+
        ' VALOR_BRUTO, '+
        ' VALOR_LIQUIDO, '+
        ' VALOR_SERVICO_REDE, '+
        ' QTDE_CONTRATOS, '+
        ' DATA_VENCIMENTO, '+
        ' CANCELADO ) '+
        ' VALUES ( ';

       sql:=Sql+QuotedStr(inttostr(Sequencia))+
                ','+
                QuotedStr(inttostr(Codigo))+
                ','+
                QuotedStr(dmc.cdsCredArquivosID.AsString)+
                ','+
                QuotedStr(cdsLiquidacaoNormalEMPRESA_CODIGO.AsString)+
                ','+
                QuotedStr(inttostr(cdsLiquidacaoNormalRESERVADO.AsInteger))+
                ','+
                
QuotedStr(FormatDateTime('mm/dd/yyyy',cdsLiquidacaoNormalDATA_COMPRA.AsDateTime))+
                ','+
                
QuotedStr(FloatToStr(dmc.DBRound(cdsLiquidacaoNormalVALOR_BRUTO.Value,2)))+
                ','+
                
QuotedStr(FloatToStr(dmc.DBRound(cdsLiquidacaoNormalVALOR_LIQUIDO.Value,2)))+
                ','+
                
QuotedStr(FloatToStr(dmc.dbRound(cdsLiquidacaoNormalVALOR_SERVICO_REDE.Value*-1,2)))+
                ','+
                
QuotedStr(inttostr(cdsLiquidacaoNormalQTDE_CONTRATOS.AsInteger))+
                ','+
                
QuotedStr(FormatDateTime('mm/dd/yyyy',cdsLiquidacaoNormalDATA_VENCIMENTO.AsDateTime))+
                ','+
                QuotedStr('N');
         end;
   sql:=sql+')';
   sqlOS.SQL.Clear;
   sqlOS.SQL.Add(sql);
   try
     sqlOS.ExecSQL;
   except
     inc(Erros_Insert);
   end;


   DecimalSeparator:=',';



function TDMC.DBRound(Value: Extended; Decimals: integer): Extended;
  var
   Factor, Fraction: Extended;
begin
   Factor := IntPower(10, Decimals);
   Value := StrToFloat(FloatToStr(Value * Factor));
   Result := Int(Value);
   Fraction := Frac(Value);
   if Fraction >= 0.5 then Result := Result + 1
   else if Fraction <= -0.5 then Result := Result - 1;
   Result := Result / Factor;
end;






Mais detalhes sobre a lista de discussão lista