CREATE OR REPLACE PROCEDURE sp_fco_baja_sucursales
(
    i_compania      char,
    i_sucursal	    char
)
AS
	vnm_existe	number(1);
BEGIN
	vnm_existe := 0;    
	BEGIN
		SELECT 1 INTO vnm_existe
		FROM fco_sucursales
    WHERE compania = i_compania And
    sucursal = i_sucursal;
	EXCEPTION
		WHEN OTHERS THEN
		raise_application_error(-20001, 'El registro a eliminar en [fco_sucursales] no existe');
		return;
	END;

	BEGIN	
    DELETE FROM fco_sucursales
    WHERE
      	compania = i_compania And
      	sucursal = i_sucursal;
	EXCEPTION
		WHEN OTHERS THEN
		raise_application_error(-20001, 'Error al eliminar de la tabla [fco_sucursales]');
		return;
	END;
	COMMIT WORK;
END;
/
CREATE PUBLIC SYNONYM sp_fco_baja_sucursales FOR ADAM.sp_fco_baja_sucursales;
GRANT EXECUTE ON sp_fco_baja_sucursales TO adama;



