PLSQL_Part_3 - PL/SQL PARTTHREE Function syntax Create or...

Info icon This preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
PART THREE PL/SQL
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Function syntax Create or Replace FUNCTION fun_name (param-list) RETURN datatype IS Declarations BEGIN Statements; RETURN value; EXCEPTION Handlers; END;
Image of page 2
Example 1  Create or Replace FUNCTION Test_fun (number1 IN Number, number2 IN Number, number3 IN Number) RETURN INTEGER IS BEGIN IF number3 BETWEEN number1 AND number2 THEN RETURN 1; ELSE RETURN 0; END IF; END;
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Cursor  In its simplest form, you can think of a cursor as  a pointer  into a  table in the database. A cursor is a variable that can be used to access the result of  particular SQL query. It can  move sequentially from row to row. For example, the following cursor declaration associates the  entire employee table with the cursor named employee_cur: DECLARE CURSOR employee_cur IS SELECT * FROM employee; The most important benefit of the cursor variable is that it provides a  mechanism for passing results of queries (the rows returned by fetches against  a cursor) between different PL/SQL programs
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern