Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am not getting the input for my code, the procedure compiled but i am not getting any result what I supposed to see, Please

I am not getting the input for my code, the procedure compiled but i am not getting any result what I supposed to see, Please take a look at my code and fix it. Thank you,
SET SERVEROUTPUT ON;
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 js.accid, at.username
FROM js_account js
JOIN account_t at ON js.accid = at.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 js.skid, js.sklvl
FROM job_skills js
WHERE js.jobid = v_job_post_id
) LOOP
SELECT COUNT(*)
INTO v_skill_count
FROM app_skills aps
WHERE aps.accid = r_job_seeker.accid AND aps.skid = r_skill.skid AND aps.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;
/
BEGIN
generate_job_alerts(v_jobid =>1, v_timestamp => SYSTIMESTAMP);
END;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions