viernes, 30 de octubre de 2015

Creación de inserciones básicas.

Se han empezado a crear los Inserts básicos de datos para el mantenimiento en la base de datos y pronto se empezaran para hacer inserts desde la aplicación, algunos ejemplos son:

Insertar datos de deudores:

CREATE PROCEDURE [dbo].[ARSP_DebtorInsert]
-- Add the parameters for the stored procedure here
@id int,
@Name varchar(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

    -- Insert statements for procedure here
INSERT INTO [dbo].[Debtor]
           ([ID]
           ,[Name]
           ,[Deleted])
     VALUES
           (@id
           ,@Name
           ,0)
END

GO

Insertar datos de Loan:
CREATE PROCEDURE [dbo].[ARSP_LoanInsert]
-- Add the parameters for the stored procedure here
@id int,@originalamount money,@fee money,@loantype int,@deadline int,@debtor int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

DECLARE @remterm INT
SELECT @remterm = LT.TermMonths
FROM dbo.LoanType LT INNER JOIN dbo.Loan L on L.FK_LoanType = LT.ID
WHERE LT.ID = @loantype

    -- Insert statements for procedure here
INSERT INTO [dbo].[Loan]
           ([ID]
           ,[OriginalAmount]
           ,[Fee]
           ,[RemainingTerm]
           ,[NonAppliedBalance]
           ,[AppliedBalance]
           ,[MonthAcumInterest]
           ,[Deadline]
           ,[FK_LoanType]
           ,[FK_Debtor]
           ,[Deleted])
     VALUES
           (@id
           ,@originalamount
           ,@fee
           ,@remterm
           ,0
           ,@originalamount
           ,0
           ,@deadline
           ,@loantype
           ,@debtor
           ,0)
END

GO

El tiempo que se duro fue 15 minutos mas las modificaciones de los deleted.

Se han tenido problemas con los movimientos que se tienen que hacer día a día ya que a veces se ejecutan pero no se terminan al  100% pero se solucionara cuando agreguemos las transacciones a los SP.

No hay comentarios:

Publicar un comentario