CREATE OR REPLACE PROCEDURE sp_fco_cambio_pension
(
	CIA  		char,
	TABLA  		varchar2,
	COD_TRAB	char,
	C11A  		char,
	C13A  		char,
	C13B  		char,
	C13C  		char,
	C13D  		char,
	C13E  		char,
	C13F  		char,
	C13G  		char,
	C13H  		char,
	C13I  		char,
	C13J  		char,
	C13K  		char,
	C13L  		char,
  C14A      number,
  C15A      number,
  C17A      number,
  C18A      number,
  C19A      number,
  C20A      number,
  C20B      number,
  C22A      number,
  C23A      number
)
/******************************************************************************************/
/*** Nombre:      sp_fco_cambio_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
	w_sql  VARCHAR2(3000);
	nombre_cursor	integer;
	iRows		integer;
BEGIN
	w_sql := 'UPDATE ' || TABLA ||
     	' SET' ||
	' C11A=''' || NVL(C11A,'C') || ''',' ||
     	' C13A=''' || NVL(C13A,'') || ''',' ||
     	' C13B=''' || NVL(C13B,'') || ''',' ||
     	' C13C=''' || NVL(C13C,'') || ''',' ||
     	' C13D=''' || NVL(C13D,'') || ''',' ||
     	' C13E=''' || NVL(C13E,'') || ''',' ||
     	' C13F=''' || NVL(C13F,'') || ''',' ||
     	' C13G=''' || NVL(C13G,'') || ''',' ||
     	' C13H=''' || NVL(C13H,'') || ''',' ||
     	' C13I=''' || NVL(C13I,'') || ''',' ||
     	' C13J=''' || NVL(C13J,'') || ''',' ||
     	' C13K=''' || NVL(C13K,'') || ''',' ||
     	' C13L=''' || NVL(C13L,'') || ''',' ||
      ' C14A=' || NVL(TO_CHAR(C14A), '0') || ',' ||
      ' C15A=' || NVL(TO_CHAR(C15A), '0') || ',' ||
      ' C17A=' || NVL(TO_CHAR(C17A), '0') || ',' ||
      ' C19A=' || NVL(TO_CHAR(C19A), '0') || ',' ||
      ' C20A=' || NVL(TO_CHAR(C20A), '0') || ',' ||
      ' C20B=' || NVL(TO_CHAR(C20B), '0') || ',' ||
      ' C22A=' || NVL(TO_CHAR(C22A), '0') || ',' ||
      ' C23A=' || NVL(TO_CHAR(C23A), '0') || 
    	' WHERE CIA=''' || CIA || '''' ||
    	' AND COD_TRAB=''' || COD_TRAB || '''';
        BEGIN
		nombre_cursor := dbms_sql.open_cursor;
		dbms_sql.parse(nombre_cursor, w_sql, dbms_sql.v7);
		iRows := dbms_sql.execute(nombre_cursor);
		dbms_sql.close_cursor(nombre_cursor);
	EXCEPTION
        	WHEN OTHERS THEN
		raise_application_error(-20001, 'Error al Actualizar la Tabla');
		return;
	END;
	commit work;
END;
/
CREATE PUBLIC SYNONYM sp_fco_cambio_pension FOR ADAM.sp_fco_cambio_pension;
GRANT EXECUTE ON sp_fco_cambio_pension TO adama;
