You are on page 1of 11

Al.I.

Cuza University of Iai


Faculty of Economics and Business Administration
Department of Accounting, Information Systems
and Statistics

DataBase Logic in
Business
Applications
Introduction to
Oracle PL/SQL
By Marin Fotache & Co.

The Need for Code


SQL

is the universal data language


(intergalactic dataspeak M. Stonebraker)
SQL acceptance is mainly due to its
declarativity, i.e. you dont need to code
anything, but to just specifiy what data you
neeed
For a while (SQL-89 and SQL-92), SQL was purely
declarative
In SQL:1999 standard PSM (Persistent Stored
Modules) was added
Real-world applications require procedures
performing tasks not possible using only SQL
statements (UPDATE, SELECT, )

SQL Procedural Extensions


Main

database servers implemented


procedural SQL extensions (programming
languages for databases) since early 1990s
Procedural extensions used to be very
different in syntax; in recent years similarities
have increased among languages
Every DB server has one or more
programming languages for
writing/developing code to be launched on
the DB server stored procedures
Stored procedures (procedures, functions,
packages, triggers) are part of the database

Examples of programming languages


available in some DB servers
Oracle:

PL/SQL, Java, C, C++, C#, Visual Basic, COBOL


IBM

DB2:

SQL PL, C++, COBOL, Fortran, Java, Perl, PHP,


Python, Ruby/Ruby on Rails, REXX, C#, VB .NET and
other .NET languages
Microsoft

SQL Server:

Transact SQL (T-SQL), C# VB .NET and other .NET


languages
PostgreSQL:

PL/Java (Java), PL/PHP (PHP), PL/Py (Python), PL/R


(R), PL/Ruby (Ruby), PL/Scheme (Scheme), PL/sh
(Unix shell)

PL/SQL
The

main language for programming


Oracle database applications
Our main focus for this semester
Easy to understand, even by nonprogrammers
Does not provide the richness of other
languages of C#, Java, Python, C++ etc.
because it addressed maily the data
processing in Oracle
Simplicity makes it very easy-to-learn
and stable

Oracle PL/SQL Code


PL/SQL

code is organized in blocks


Anonymous blocks are stored outside
the database in text (usually .sql) files
Named blocks reside with the database
stored procedures:
Procedures
Functions
Packages
User-defined packages
System packages

Triggers

Useful Resources on Basic PL/SQL


Getting

started PL/SQL tutorial


http://www.way2tutorial.com/plsql/tutorial.php
PL/SQL Tutorial (TutorialsPoint)
http://www.tutorialspoint.com/plsql/index.htm
pl/sql tutorial
http://plsql-tutorial.com
PL/SQL Tutorial
http://www.plsqltutorial.com
Fotache et. 2003, Fotache 2009 (in Romanian) uploaded on FEAA portal)
An older video-tutorial (in Romanian):
03_Primele blocuri PL SQL.mp4
http://1drv.ms/1yX0l61

First PL/SQL topics in recommended


tutorials
Block

Structure
Data Types
Variable & Scope
Constant Declaration
Comments
Conditional Control
Loop Statement
Sequential Control
Case Statement
Functions
Procedures

Video-tutorials on Basic PL/SQL


PL1

PL SQL Tutorial Introduction to PL SQL programming


https://www.youtube.com/watch?v=Wvl_zDdvUuE
PL2 PL SQL Tutorial Declaration Section Theory)
https://www.youtube.com/watch?v=Wf-OoqxG4uE&spfreload=1
0
PL3 PL SQL Tutorial Declaration Section Hands On)
https://www.youtube.com/watch?v=C4tEDxg_EiY
PL4 PL SQL Tutorial Displaying Strings and Assignment
Theory)
https://www.youtube.com/watch?v=ltZhhnnfp2o
PL5 PL SQL Tutorial DBMS OUTPUT and Assignment Hands On)
https://www.youtube.com/watch?v=LTEoCZhmigI
PL6 PL SQL Tutorial Programs to Try based on PL1 PL5
https://www.youtube.com/watch?v=IqlGhAWOwvk&spfreload=1
0
PL7 PL SQL Tutorial SELECT statements in PL SQL blocks

Video-tutorials on Basic PL/SQL (cont.)


PL8

PL SQL Tutorial Select statements in a PL SQL block Hands

On)
https://www.youtube.com/watch?v=-OPoHSArODE&spfreload=10
PL9 PL SQL Tutorial DML and TCL statements Theory)
https://www.youtube.com/watch?v=T7SJcoNhRvE
PL10 PL SQL Tutorial DML and TCL statements Hands On)
https://www.youtube.com/watch?v=Q76d25yRlxs
PL11 PL SQL Tutorial IF statements in PL SQL Theory)
https://www.youtube.com/watch?v=kHCUitCcHSE&spfreload=10
PL12 PL SQL Tutorial IF statements in PL SQL Hands On)
https://www.youtube.com/watch?v=fd1ZvJpx458&spfreload=10
PL13 PL SQL Tutorial CASE Statement in PL SQL Theory)
https://www.youtube.com/watch?v=w3ERdbPcXZo&spfreload=10
PL14 PL SQL Tutorial CASE Statement in PL SQL Hands On)
https://www.youtube.com/watch?v=uPDZlBte18M&spfreload=10
PL15 PL SQL Tutorial LOOP END LOOP statement Theory)
https://www.youtube.com/watch?v=ZYFwp9VQC6A&spfreload=10

Video-tutorials on Basic PL/SQL (cont.)


PL16

PL SQL Tutorial Loop Statement Hands On))


https://www.youtube.com/watch?v=IgJI1Q_VxZo
PL17 PL SQL Tutorial WHILE LOOP construct Theory)
https://www.youtube.com/watch?v=00ZCPpP3ZrA&spfreloa
d=10
PL18 PL SQL Tutorial While Loop Statement Hands On)
https://www.youtube.com/watch?v=zP1Yfj_oBN0
PL19 PL SQL Tutorial For LOOP construct Theory)
https://www.youtube.com/watch?v=SrSrzwNjI40
PL20 PLSQL Tutorial FOR LOOP in PL SQL Hands On)
https://www.youtube.com/watch?v=gVWHt0qD9ig

See also video-tutorials from PLS-1 to PLS-8 in the playlist: