After I'm executing this I receive the following:
PL/SQL: ORA-00942: table or view does not exist
PLS-00364: loop index variable 'EMP_REC' use is invalid
In a block or subprogram, user-defined records are instantiated when you enter the block or Subprogram. They cease to exist when you exit the block Subprogram."
TYPE t_rec IS RECORD
(v_sal NUMBER(8) NOT NULL := 0,
v_min_sal NUMBER(8) DEFAULT 1000,
v_myrec.v_sal := v_myrec.v_min_sal + 500;
v_myrec.v_hire_date := SYSDATE;
WHERE employee_id = 100;
FOR emp_rec IN (SELECT *
They are separate errors;
PLS-00364: loop index variable 'EMP_REC' use is invalid is a knock-on error from your cursor being invalid when it's declared, which gets
PL/SQL: ORA-00942: table or view does not exist.
v_myrec is not a table. If it was a SQL (schema-level) collection type rather than a PL/SQL collection you could do:
FOR emp_rec IN (SELECT * FROM TABLE(v_myrec))
but it isn't, so you can't. You can't refer to a PL/SQL collection in plain SQL, even inside a PL/SQL block. And this isn't even a collection, it's just a single record type, so looping over it doesn't really make much sense anyway.