Chapter 13 Functions
1) | Write a stored function called new_student_id that takes in no parameters and returns a student.student_id%TYPE. The value returned will be used when inserting a new student into the CTA application. It will be derived by using the formula: student_id_seq.NEXTVAL. |
A1: |
Answer: Your answer should look similar to the following:
CREATE OR REPLACE FUNCTION new_student_id RETURN student.student_id%TYPE AS v_student_id student.student_id%TYPE; BEGIN SELECT student_id_seq.NEXTVAL INTO v_student_id FROM dual; RETURN(v_student_id); END; |
2) | Write a stored function called zip_does_not_exist that takes in a zipcode.zip%TYPE and returns ... |
Get Oracle® PL/SQL® Interactive Workbook, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.