I need help with an SQL problem. I forgot it was due and now I can\'t even focus
ID: 3553352 • Letter: I
Question
I need help with an SQL problem. I forgot it was due and now I can't even focus on how to start. Here's the instructions for the assignment. Thank you so much for any help.
Write an PL/SQL procedure to add new employee to your employee5 table. Your procedure should take the following input parameters:
EMP_FIRST_NAME
EMP_LAST_NAME
EMP_AGE
EMP_TITLE
CITY
STATE
Note that the employee id is not passed as a parameter. Therefore, you need to create a sequence to generate the id number when inserting a new record.
Explanation / Answer
create sequence emp_id_seq start with 1;
CREATE OR REPLACE PROCEDURE insert_emp
( EMP_FIRST_NAME IN VARCHAR2,
EMP_LAST_NAME IN VARCHAR2,
EMP_AGE IN NUMBER,
EMP_TITLE IN VARCHAR2,
CITY IN VARCHAR2,
STATE IN VARCHAR2)
IS
BEGIN
INSERT INTO emp (emp_id, fname, lname, age, title, city, state)
VALUES (emp_id_seq.nextval, EMP_FIRST_NAME, EMP_LAST_NAME, EMP_AGE, EMP_TITLE, CITY, STATE);
commit;
END;
/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.