IF EXISTS (SELECT 1 FROM dbo.sysobjects WHERE ID = OBJECT_ID(N'[dbo].[sp_fco_cambio_riesgos]') 
AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   DROP PROCEDURE dbo.sp_fco_cambio_riesgos
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE dbo.sp_fco_cambio_riesgos
(
	@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  		numeric(2,0),
  @C14A           numeric(2,0),
  @C15A           numeric(9,0),
  @C17A           numeric(9,0),
	@C28A  		numeric(9,0),
	@C28B  		numeric(9,0),
  @C29A           numeric(9,0),
  @C30A           varchar(5),
  @C30B           varchar(5)
)
/******************************************************************************************/
/*** Nombre:      sp_cambio_mf_riesgos                                                	***/
/*** Modulo:      ADAM V3. (Fiscal Colombiano)                                          ***/
/*** Descripcion: permite al usuario corregir las leves inconsistencias que             ***/
/***    ocasionalmente puedan presentarse en el reporte ALA ARP             		***/
/***              o en el medio magnético        					***/
/******************************************************************************************/
AS
DECLARE	@sql  VARCHAR(2000), 
    @vvc_sql2 varchar(2000)

BEGIN
	SET @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(convert(varchar,@C13K),"0") + ","

	SET @vvc_sql2 =
     	" C14A=" + IsNull(convert(varchar,@C14A),"0") + "," +
     	" C15A=" + IsNull(convert(varchar,@C15A),"0") + "," +
     	" C17A=" + IsNull(convert(varchar,@C17A),"0") + "," +
     	" C28A=" + IsNull(convert(varchar,@C28A),"0") + "," +
     	" C28B=" + IsNull(convert(varchar,@C28B),"0") + "," +
     	" C29A=" + IsNull(convert(varchar,@C29A),"0") + "," +
     	" C30A='" + IsNull(@C30A,"") + "'," +
     	" C30B='" + IsNull(@C30B,"") + "'" +
    	" WHERE CIA='" + @CIA + "'" +
    	" AND COD_TRAB='" + @COD_TRAB + "'" +
    	" AND C17A <> 0"

	EXECUTE (@sql + @vvc_sql2)

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


GO
GRANT EXECUTE ON sp_fco_cambio_riesgos TO Public
GO