What I intend is to create a procedure that updates the sale price of a piece whose price is passed by parameter, this will be done only if the new price is greater than the existing one in the database. For now I want to do it without exceptions, and later add them if it can be.
The issue is that it gives me a fault, indicating that there is an IS of more, but I have similar ones and in principle I think the structure is like that, I declare a cursor because the execution of the query gives more than one row, what I want to enter the cursor locate the price, and if it is higher, update it as a parameter.
CREATE OR REPLACE PROCEDURE actualizarPrecio (precioNuevo PIEZAS.PRECIO_VENTA%TYPE,modeloa PIEZAS.MODELO%TYPE)
IS
cursorx IS
SELECT PRECIO_VENTA FROM PIEZAS WHERE MODELO=modeloa;
resulta number;
BEGIN
FOR v_reg IN cursorx LOOP
IF (precioNuevo > precio_venta) THEN
UPDATE PIEZAS SET PRECIO_VENTA=precioNuevo WHERE MODELO=modeloa;
resulta:= cursorx%ROWCOUNT;
ELSE
DBMS_OUTPUT.PUT_LINE('No se puede actualizar el precio ');
END IF;
END LOOP;
CLOSE cursorx;
DBMS_OUTPUT.PUT_LINE('Filas actualizadas ' ||resulta);
END;