CREATE PROCEDURE change_navi_and_etc
AS
BEGIN
	DECLARE @car_management_no char(6);
	DECLARE @car_navigation char(1);
	DECLARE @etc char(1);

	DECLARE rentCarList CURSOR FOR
		SELECT
			car_management_no,
			car_navigation,
			etc
		FROM nmrm_rent_car
		WHERE car_navigation = '0' AND etc = '1'
		   OR car_navigation = '1' AND etc = '0';

	OPEN rentCarList;

	FETCH NEXT FROM rentCarList
	INTO @car_management_no,
		 @car_navigation,
		 @etc;

	WHILE @@FETCH_STATUS = 0
	BEGIN
		IF @car_navigation = '1'
		BEGIN
			UPDATE nmrm_rent_car
			SET car_navigation = '0',
				etc = '1'
			WHERE car_management_no = @car_management_no;
		END
		ELSE
		BEGIN
		BEGIN
			UPDATE nmrm_rent_car
			SET car_navigation = '1',
				etc = '0'
			WHERE car_management_no = @car_management_no;
		END
		END

		FETCH NEXT FROM rentCarList
		INTO @car_management_no,
			 @car_navigation,
			 @etc;
	END

	CLOSE rentCarList;
	DEALLOCATE rentCarList;
END;
