Ver Mensaje Individual
  #4  
Antiguo 25-01-2010
Ricardojosep Ricardojosep is offline
Miembro
 
Registrado: sep 2003
Ubicación: Sgo del estero (Argentina)
Posts: 75
Reputación: 21
Ricardojosep Va por buen camino
Aqui va el codigo

Hola Casimiro, Marcos, muchas gracias por su respuesta. Aqui paso a poner el codigo que hace delphi para hacer el grabado en la base, realmente todo se hace por procedimiento almacenado, asique pongo las dos cosas...

Código Delphi [-]
Base.StartTransaction;
Error := False;
Estado := True;
GrabaVenta.ParamByName('ITOTAL').AsFloat := StrToFloat(TotalPesos.Caption);

Try
  GrabaVenta.ExecProc;
Except
  Error := True;
End;

For I := 1 To DetalleVenta.RowCount - 1 Do
  Begin
    GrabaDetalleVenta.ParamByName('IFACTURA').AsInteger := GrabaVenta.ParamByName('Factura').AsInteger;
    GrabaDetalleVenta.ParamByName('IITEM').AsInteger := StrToInt(DetalleVenta.Cells[0, I]);
    GrabaDetalleVenta.ParamByName('IID').AsInteger := StrToInt(DetalleVenta.Cells[1, I]);
    GrabaDetalleVenta.ParamByName('ICANTIDAD').AsInteger := StrToInt(DetalleVenta.Cells[3, I]);
    GrabaDetalleVenta.ParamByName('IPRECIO').AsFloat := StrToFloat(DetalleVenta.Cells[4, I]);

     Try
       GrabaDetalleVenta.ExecProc;
     Except
        Error := True;
     End;
  End;

If Not Error Then
  Base.Commit;
Else
  Base.Rollback;

Ahora bien, los procedimientos almacenados que realizan la grabacion, son:

Grabar_Factura;

Código SQL [-]
=============================================================================
DECLARE VARIABLE fact BIGINT;
BEGIN
  /* Procedure body */
  SELECT gen_id(Ventas_Factura_GEN,1) FROM RDB$DATABASE INTO :fact;
  INSERT INTO ventas VALUES (:fact, 'A', '', current_date, current_time, :itotal);
  factura = :fact;
  SUSPEND;
END
=============================================================================
Parameters:
ITOTAL                            INPUT DOUBLE PRECISION
FACTURA                           OUTPUT BIGINT

y Grabar_Detalle_Factura;

Código SQL [-]
=============================================================================
BEGIN
  /* Procedure body */
  INSERT INTO detalle_venta VALUES (:iFACTURA, :iITEM, :iID, :iCANTIDAD, :iPRECI
O, :iDESCUENTO);
  SUSPEND;
END
=============================================================================
Parameters:
IFACTURA                          INPUT BIGINT
IITEM                             INPUT INTEGER
IID                               INPUT INTEGER
ICANTIDAD                         INPUT INTEGER
IPRECIO                           INPUT DOUBLE PRECISION
IDESCUENTO                        INPUT SMALLINT

Con respecto a lo que me dice Marcos la propiedad CachedUpdates del TZStoreProc esta en false...

Muchas gracias por la ayuda, hasta luego!

Saludos!!

Ricardo
__________________
La amistad es la union de dos almas para formar una sola.
Responder Con Cita