Book Image

Oracle Database XE 11gR2 Jump Start Guide

By : Asif Momen
Book Image

Oracle Database XE 11gR2 Jump Start Guide

By: Asif Momen

Overview of this book

Oracle Database XE 11gR2 is an excellent beginner-level database and is a great platform to learn database concepts. "Oracle Database XE 11gR2 Jump Start Guide" helps you to install, administer, maintain, tune, back up and upgrade your Oracle Database Express Edition. The book also helps you to build custom database applications using Oracle Application Express.Using this book, you will be able to install Oracle Database XE on Windows/Linux operating system.This book helps you understand different database editions and it guides you through the installation procedure with the aid of screenshots. You will learn to interact with the database objects. You will gain a solid understanding of stored sub-programs which is followed by an introduction to Oracle Application Express (APEX). Solid database performance tuning strategies are also discussed in this book followed by backup and recovery scenarios. All in all, "Oracle Database XE 11gR2 Jump Start Guide" delivers everything that you should know to get started with Oracle Database administration.
Table of Contents (20 chapters)
Oracle Database XE 11gR2 Jump Start Guide
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface

Creating stored subprograms


You create a stored subprogram using the CREATE PROCEDURE command. In this section, let us create a sample stored procedure in the HR schema and name it salary_increment. The stored procedure does the following:

  1. 1. Accepts EMP_NO as input.

  2. 2. Fetches the current salary of the employee.

  3. 3. Calculates the increment on the salary.

  4. 4. If the salary is greater than 1000 then raise it by 2 percent. If the salary is between 501 and 999, increment it by 5 percent, and if the salary is less than or equal to 500, increment it by 10 percent.

  5. 5. Increment the salary of the given employee in the EMP table.

  6. 6. Commits the changes.

The following is a screenshot of a PL/SQL stored procedure:

At this point you should be able to successfully create the salary_increment procedure. Before we execute this procedure, let us make a note of the salary of "Tom Green" by querying the EMP table. The following screenshot shows the query:

From the query shown in the preceding screenshot, we know...