4. For this problem create a table called instructor_course_nums. Write a procedure that accepts an instructor ID as input. The procedure calculates the total number of course sections taught by that instructor, and adds a tuple to the instructor_course_nums table consisting of the instructors ID number, name, and total courses taught - call these attributes: ID, name, and tot_courses. If the instructor already has an entry in the table, then the procedure makes sure the total number of courses taught in the instructor_course_nums table is up-to-date. You must name your procedure: __insCourseNums Proc Where is your last name and is the day of the month you were born. Below is an example of how I named my procedure:
Hi,
This is what I have, but I am stuck with what to write and not sure if my function is even correct, to begin with. Can someone show me a walk-through solution? Please read all directions and don't just apply any SQL syntax as I must use postgreSQL.
MUST USE postgreSQL - LANGUAGE plpgsql
The tables instructor and teaches have been created as I am working with an existing
CODE
CREATE TABLE instructor_course_nums (ID VARCHAR(25), name VARCHAR(25), tot_courses VARCHAR(25));
CREATE OR REPLACE PROCEDURE calculate_instr_course(ID VARCHAR(25), name VARCHAR(25), tot_courses VARCHAR(25))
LANGUAGE plpgsql
AS
$$
BEGIN
SELECT name INTO instructor_course_nums FROM instructor
WHERE ID = instructor.ID;
SELECT COUNT(*) INTO instructor_course_nums FROM teaches
WHERE instructor_course_nums.ID = teaches.ID;
END;
$$;
Trending now
This is a popular solution!
Step by step
Solved in 2 steps