Question: Please help me fix the error of my SQL code, I will provide my actual code as well as the error I am getting. Thank

Please help me fix the error of my SQL code, I will provide my actual code as well as the error I am getting. Thank You.
Procedure GENERATE_JOB_ALERTS compiled
LINE/COL ERROR
----------------------------------------------------------------------
11/9 PL/SQL: SQL Statement ignored
11/16 PL/SQL: ORA-00918: column ambiguously defined
40/13 PL/SQL: SQL Statement ignored
41/27 PLS-00364: loop index variable 'R_JOB_SEEKER' use is invalid
41/27 PL/SQL: ORA-00904: "R_JOB_SEEKER"."ACCID": invalid identifier
52/13 PL/SQL: SQL Statement ignored
53/42 PLS-00364: loop index variable 'R_JOB_SEEKER' use is invalid
53/55 PL/SQL: ORA-00984: column not allowed here.
The actual code:
CREATE OR REPLACE PROCEDURE generate_job_alerts (v_jobid IN NUMBER, v_timestamp IN TIMESTAMP) AS
-- Cursor to find the job post and check if it is active
CURSOR cur_job_post IS
SELECT min_degree, min_years_work_exp, jobid
FROM job_post
WHERE jobid = v_jobid AND j_status =1;
-- Cursor to find job seekers who meet the degree and work experience requirements
CURSOR cur_job_seekers (p_degree NUMBER, p_experience NUMBER) IS
SELECT accid, username
FROM js_account JOIN account_t ON js_account.accid = account_t.accid
WHERE degree >= p_degree AND num_yrs_wrk_xp >= p_experience;
-- Variables to hold job requirements
v_min_degree NUMBER;
v_min_years_work_exp NUMBER;
v_job_post_id NUMBER;
-- Variables for checking skills
v_skill_count NUMBER;
flag INT;
BEGIN
OPEN cur_job_post;
FETCH cur_job_post INTO v_min_degree, v_min_years_work_exp, v_job_post_id;
IF cur_job_post%NOTFOUND THEN
DBMS_OUTPUT.PUT_LINE('Invalid job post ID');
CLOSE cur_job_post;
RETURN;
END IF;
-- Loop through all qualified job seekers
FOR r_job_seeker IN cur_job_seekers(v_min_degree, v_min_years_work_exp) LOOP
flag :=1;
-- Check each required skill and level
FOR r_skill IN (SELECT skid, sklvl FROM job_skills WHERE jobid = v_job_post_id) LOOP
SELECT COUNT(*) INTO v_skill_count FROM app_skills
WHERE accid = r_job_seeker.accid AND skid = r_skill.skid AND sklvl >= r_skill.sklvl;
IF v_skill_count =0 THEN
flag :=0;
EXIT;
END IF;
END LOOP;
IF flag =1 THEN
-- If all conditions are met, print and insert into message table
DBMS_OUTPUT.PUT_LINE('A job post '|| v_job_post_id ||' is available and you are qualified to apply');
INSERT INTO message (mid, appid, mtime, mbody)
VALUES (message_seq.nextval, r_job_seeker.accid, v_timestamp, 'A job post '|| v_job_post_id ||' is available and you are qualified to apply');
END IF;
END LOOP;
CLOSE cur_job_post;
END;
Errors: check compiler log

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!