Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Advanced Oracle PL/SQL Developer's Guide (Second Edition) - Second Edition

You're reading from  Advanced Oracle PL/SQL Developer's Guide (Second Edition) - Second Edition

Product type Book
Published in Feb 2016
Publisher
ISBN-13 9781785284809
Pages 428 pages
Edition 2nd Edition
Languages
Author (1):
Saurabh K. Gupta Saurabh K. Gupta
Profile icon Saurabh K. Gupta

Table of Contents (19) Chapters

Advanced Oracle PL/SQL Developer's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Overview of PL/SQL Programming Concepts Oracle 12c SQL and PL/SQL New Features Designing PL/SQL Code Using Collections Using Advanced Interface Methods Virtual Private Database Oracle SecureFiles Tuning the PL/SQL Code Result Cache Analyzing, Profiling, and Tracing PL/SQL Code Safeguarding PL/SQL Code against SQL injection Working with Oracle SQL Developer Index

A sample PL/SQL program


Before we plunge into code analysis techniques, let us write down a standard PL/SQL program for demonstrating code analysis, profiling, and tracing. The following PL/SQL procedure calculates the score of a user in an exam (Note that negative scoring is applicable). The procedure P_CALC_USER_POINTS declares a local function and a procedure to calculate the points:

/*Create a PL/SQL procedure*/
CREATE OR REPLACE PROCEDURE p_calc_user_points
(p_user VARCHAR2 DEFAULT USER, p_correct NUMBER, p_wrong NUMBER)
IS
 l_num NUMBER;

 /*A local function F_CALC_POINTS */
 FUNCTION f_calc_points (p_ques NUMBER, p_factor NUMBER)
 RETURN NUMBER
 IS
 BEGIN
  RETURN (p_ques*p_factor);
 END;

 /*A local procedure */
 PROCEDURE P_NET_CALC (p_net_points OUT NUMBER) IS
 BEGIN
  p_net_points := f_calc_points (p_correct,4) + f_calc_points (p_wrong,-2);
 END;

/*Main procedure body */
BEGIN
 p_net_calc (l_num);
 DBMS_OUTPUT.PUT_LINE (USER||' earned '||TO_CHAR (l_num)||' points');
END;
/

We will...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}