IF EXISTS (SELECT 1 FROM dbo.sysobjects WHERE ID = OBJECT_ID(N'[dbo].[sp_fco_cambio_pension]') 
AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   DROP PROCEDURE dbo.sp_fco_cambio_pension
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE dbo.sp_fco_cambio_pension
(
	@CIA  		char(4),
	@TABLA  	varchar(30),
	@COD_TRAB	char(10),
	@C11A  		char(4),
	@C13A  		char(1),
	@C13B  		char(1),
	@C13C  		char(1),
	@C13D  		char(1),
	@C13E  		char(1),
	@C13F  		char(1),
	@C13G  		char(1),
	@C13H  		char(1),
	@C13I  		char(1),
	@C13J  		char(1),
	@C13K  		char(1),
	@C13L  		char(1),
  @C14A           numeric(2,0),
  @C15A           numeric(9,0),
  @C17A           numeric(9,0),
  @C18A           numeric(9,4),
  @C19A           numeric(9,0),
  @C20A           numeric(9,0),
  @C20B           numeric(9,0),
  @C22A           numeric(9,0),
  @C23A           numeric(9,0)
)
/******************************************************************************************/
/*** Nombre:      sp_cambio_mf_pension                                             	***/
/*** Modulo:      ADAM V3. (Fiscal Colombiano)                                          ***/
/*** Descripcion: permite al usuario corregir las leves inconsistencias que             ***/
/***    ocasionalmente puedan presentarse en el reporte ALA Pensiones          		***/
/***              o en el medio magnético        					***/
/******************************************************************************************/
AS
DECLARE	@sql  VARCHAR(3000)

BEGIN
	SELECT @sql = "UPDATE " + @TABLA +
     	" SET" +
	" C11A='" + IsNull(@C11A,"C") + "'," +
     	" C13A='" + IsNull(@C13A,"") + "'," +
     	" C13B='" + IsNull(@C13B,"") + "'," +
     	" C13C='" + IsNull(@C13C,"") + "'," +
     	" C13D='" + IsNull(@C13D,"") + "'," +
     	" C13E='" + IsNull(@C13E,"") + "'," +
     	" C13F='" + IsNull(@C13F,"") + "'," +
     	" C13G='" + IsNull(@C13G,"") + "'," +
     	" C13H='" + IsNull(@C13H,"") + "'," +
     	" C13I='" + IsNull(@C13I,"") + "'," +
     	" C13J='" + IsNull(@C13J,"") + "'," +
     	" C13K='" + IsNull(@C13K,"") + "'," +
     	" C13L='" + IsNull(@C13L,"") + "'," +
        " C14A=" + IsNull(Convert(varchar,@C14A), '0') + "," +
        " C15A=" + IsNull(Convert(varchar,@C15A), '0') + "," +
        " C17A=" + IsNull(Convert(varchar,@C17A), '0') + "," +
        " C18A=" + IsNull(Convert(varchar,@C18A), '0') + "," +
        " C19A=" + IsNull(Convert(varchar,@C19A), '0') + "," +
        " C20A=" + IsNull(Convert(varchar,@C20A), '0') + "," +
        " C20B=" + IsNull(Convert(varchar,@C20B), '0') + "," +
        " C22A=" + IsNull(Convert(varchar,@C22A), '0') + "," +
        " C23A=" + IsNull(Convert(varchar,@C23A), '0') + 
    	" WHERE CIA='" + @CIA + "'" +
    	" AND COD_TRAB='" + @COD_TRAB + "'"


	EXECUTE (@sql)

     	IF @@ERROR <> 0 RAISERROR 13000 "Error al Actualizar la Tabla"
END


GO
GRANT EXECUTE ON sp_fco_cambio_pension TO Public
GO