dbo.balances_res_ie2

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
--exec [balances_res_ie2]
CREATE OR ALTER PROCEDURE dbo.balances_res_ie2
AS


BEGIN
    SET NOCOUNT ON;
 declare @id int 
 declare @res_ie decimal(16,2)

DECLARE bn CURSOR
FOR
 select convert(int,idifx), res_ie
   from tabla_res_ie2
  order by convert(int,idifx )

 OPEN bn 
 Fetch next from bn INTO @id, @res_ie
 
 WHILE (@@FETCH_STATUS <> -1 )
 BEGIN
  if (@res_ie > 0) 
  begin
   update balances_contables_new set res_otrosing = res_otrosing + @res_ie
    where idifx = @id
  end 
  else
  begin
            
   update balances_contables_new set res_otrosegr = res_otrosegr * (-1)
    where idifx = @id
      and res_otrosegr < 0 

   update balances_contables_new set res_otrosegr = res_otrosegr + (@res_ie * (-1))
    where idifx = @id 
  end 
  
    Fetch next from bn INTO @id, @res_ie
 END

 CLOSE bn
 DEALLOCATE bn 
END 

GO

Depends On

1

Used By

No items found