I want to delete rows by entering the ID hospital but for some reason I get an error when executing the procedure.
CREATE OR REPLACE PROCEDURE BorrarHospital (codihospital IN OUT NUMBER)
IS
idhospital NUMBER;
CURSOR C1 (codihospital NUMBER) IS SELECT HOSPITAL_CODI FROM HOSPITAL WHERE HOSPITAL_CODI = codihospital;
BEGIN
idhospital := codihospital;
OPEN C1 (codihospital);
FETCH C1 INTO codihospital;
IF (C1%FOUND) THEN
DELETE FROM HOSPITAL WHERE HOSPITAL_CODI = idhospital;
ELSE
DBMS_OUTPUT.PUT_LINE('No hi ha cap hospital amb aquest codi');
END IF;
COMMIT;
CLOSE C1;
END;
-
DECLARE
codihospital NUMBER;
BEGIN
BorrarHospital(99);
END;
I get this error
ORA-06550: line 6, column 16:
PLS-00363: expression '99' cannot be used as an assignment target
ORA-06550: line 6, column 1:
PL/SQL: Statement ignored
Can someone tell me what I'm doing wrong? I just started learning PL/SQL and I didn't find how I can solve this problem.