Skip to main content
PL/SQL (Procedural Language/Structured Query Language) is Oracle Corporation's procedural language extension for SQL and the Oracle relational database. PL/SQL is available in Oracle Database  TimesTen in-memory database and IBM DB2. Oracle Corporation usually extends PL/SQL functionality with each successive release of the Oracle Database.
PL/SQL includes procedural language elements such as conditions and loops. It allows declaration of constants and variables, procedures and functions, types and variables of those types, and triggers. It can handle exceptions (runtime errors). Arrays are supported involving the use of PL/SQL collections. Implementations from version 8 of Oracle Database onwards have included features associated with object-orientation. One can create PL/SQL units such as procedures, functions, packages, types, and triggers, which are stored in the database for reuse by applications that use any of the Oracle Database programmatic interfaces.

Procedure

Procedures are similar to functions, in that they are named program units that can be invoked repeatedly. The primary difference is that functions can be used in a SQL statement whereas procedures cannot. Another difference is that the procedure can return multiple values whereas a function should only return a single value.
The procedure begins with a mandatory heading part to hold the procedure name and optionally the procedure parameter list. Next are the declarative, executable and exception-handling parts, as in the PL/SQL Anonymous Block. Here is an example of a simple procedure.
CREATE PROCEDURE create_email_address ( -- Procedure heading part begins
    name1 VARCHAR2,
    name2 VARCHAR2,
    company VARCHAR2,
    email OUT VARCHAR2
) -- Procedure heading part ends
AS
-- Declarative part begins (optional)
error_message VARCHAR2(30) := 'Email address is too long.';
BEGIN -- Executable part begins (mandatory)
    email := name1 || '.' || name2 || '@' || company;
EXCEPTION -- Exception-handling part begins (optional)
WHEN VALUE_ERROR THEN
    DBMS_OUTPUT.PUT_LINE(error_message);
END create_email_address;
Advantages of Stored Procedures
To help you build powerful database applications, stored procedures provide several advantages including better performance, higher productivity, ease of use, and increased scalability.
1.Performance
Stored procedures are compiled once and stored in executable form, so procedure calls are quick and efficient. Executable code is automatically cached and shared among users. This lowers memory requirements and invocation overhead.
By grouping SQL statements, a stored procedure allows them to be executed with a single call. This minimizes the use of slow networks, reduces network traffic, and improves round-trip response time. OLTP applications, in particular, benefit because result set processing eliminates network bottlenecks.
Additionally, stored procedures enable you to take advantage of the computing resources of the server. For example, you can move computation-bound procedures from client to server, where they will execute faster. Likewise, stored functions called from SQL statements enhance performance by executing application logic within the server.

2.Scalability
Stored procedures increase scalability by isolating application processing on the server. In addition, automatic dependency tracking for stored procedures aids the development of scalable applications.
The shared memory facilities of the Multi-Threaded Server (MTS) enable Oracle8i to support more than 10,000 concurrent users on a single node. For more scalability, you can use the Net8 Connection Manager to multiplex Net8 connections.
3.Maintainability
Once it is validated, a stored procedure can be used with confidence in any number of applications. If its definition changes, only the procedure is affected, not the applications that call it. This simplifies maintenance and enhancement. Also, maintaining a procedure on the server is easier than maintaining copies on various client machines.
4.Interoperability
Within the RDBMS, Java conforms fully to the Java Language Specification and furnishes all the advantages of a general-purpose, object-oriented programming language. Also, like PL/SQL, Java provides full access to Oracle data, so any procedure written in PL/SQL can be written in Java.
PL/SQL stored procedures complement Java stored procedures. Typically, SQL programmers who want procedural extensions favor PL/SQL, and Java programmers who want easy access to Oracle data favor Java.
The RDBMS allows a high degree of interoperability between Java and PL/SQL. Java applications can call PL/SQL stored procedures using an embedded JDBC driver. Conversely, PL/SQL applications can call Java stored procedures directly.
5.Security
You can restrict access to Oracle data by allowing users to manipulate the data only through stored procedures that execute with their definer's privileges. For example, you can allow access to a procedure that updates a database table, but deny access to the table itself.
6.Replication
With Oracle Advanced Replication, stored procedures can be replicated (copied) from one Oracle8i database to another. This feature makes them ideal for implementing a central set of business rules. Once written, the stored procedures are replicated and distributed to work groups and branch offices throughout the company. In this way, policies can be revised on a central server rather than on individual servers.
7.Productivity and Ease of Use
By designing applications around a common set of stored procedures, you can avoid redundant coding and increase your productivity. Moreover, stored procedures let you extend the functionality of the RDBMS. For example, stored functions called from SQL statements enhance the power of SQL.
You can use the Java integrated development environment (IDE) of your choice to create stored procedures. Then, you can deploy them on any tier of the network architecture. Moreover, they can be called by standard Java interfaces such as JDBC, CORBA, and EJB and by programmatic interfaces and development tools such as SQLJ, the OCI, Pro*C/C++, and JDeveloper.

This broad access to stored procedures lets you share business logic across applications. For example, a stored procedure that implements a business rule can be called from various client-side applications, all of which can share that business rule. In addition, you can leverage the server's Java facilities while continuing to write applications for your favorite programmatic interface.

Comments

Popular posts from this blog

Spring Boot And Angular 4 with Angular CLI Integration

I recently spent the time to setup Angular CLI front-end using IntelliJ and Maven tool. Angular 4 is the next version of Angular 2. In this article, I am going to show how to integrate Angular 4 with SpringBoot RestAPI using IntelliJ step by step. In this article,  1. I used various technologies.  -> Maven  -> IntelliJ  -> SpringBoot  -> Java 8  -> Angular 4  ->Node.js  2. Setup Node.js and NPM.  Install Node.js from Download . And then check Node.js and NPM by node -v and npm -v command respectively. -> Open CMD in Windows and check Node.js and NPM: node -v and npm -v.   3. Install the Angular-CLI using the command line as:  -> open cmd and type npm install -g @angular/cli -> and check Angular-CLI after installing as: ng -v 4. Setup SpringBoot App using IntelliJ as: -> create a simple spring-boot restful app and dependency for the web in pom.xml file as < dependency > < groupId > org.springframework.boot </ groupI

Introduction of Regular Expression

Regular expression is an special kind of API for finding sequence of character that specifies a pattern which can be searched for in a text and data. Usually regex or regular expression can be use to search,  edit and manipulate text and data. Java Regex API provides one interface and three classes in java.regex.util package. 1. MatchResult interface A MatchResult interface represents the result of match operation. It contains query methods used to determines the results of a match against a regex. 2. Matcher class    It is a regex engine that  interprets the pattern and perform match operations on a character sequence. 3. Pattern class A Pattern object is an compiled representation of a regex. 4. PatternSyntaxException class A PatternSyntaxException object is an unchecked exception that indicates a syntax error in a regex pattern. Predefined Character classes Construct Description . Any character (may or may not match line terminators) \d A digit:  [

String vs StringBuffer vs StringBuilder

What is the difference between String, StringBuffer and StringBuilder? String: Java String object is an immutable i.e. unmodifiable. It can be created by two ways by literal and new keyword. StringBuffer: Java StringBuffer is mutable. It can be created by using the new keyword. It is a synchronized means thread-safe. StringBuilder: Java StringBuilder is mutable. It is non-synchronized means not thread-safe.