O'Reilly logo

Oracle® PL/SQL® Interactive Workbook, Second Edition by Elena Silvestrova, Benjamin Rosenzweig

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required