Database application
= { a particular database, a collection of programs to access the database}
Bank database application, Railway database application, university database application, …
• A database programming language is a programming language developed specifically for writing database application. • Writing program to access a particular database is called database programming.
1
Database programming
Approaches to database programming
i) Embedding database commands in a general-purpose programming language e.g. C/C++/C#/Java/COBOL and the likes.
Scripting languages like PHP, JavaScript for accessing database in Web application. ii) Using a library of database functions e.g. JDBC interface iii) Designing a brand new database programming language
– a language specifically designed and developed for accessing a database.
2
PL/SQL
Programming Language/SQL
• PL/SQL = SQL + Programming Language constructs
• Oracle′s PL/SQL
• PL/SQL is a Database Programming Language
• SQL standard for Database programming language is called SQL/PSM (Persistent Stored Module)
Programming language constructs
•
•
•
Sequence (a number of SQL statements meant to execute sequentially)
Selection (branching e.g. if then else, case)
Iteration (looping)
3
if, else if condition then statement list end if; if condition then statement list else statement list end if;
4
Nested if if condition then statement list if condition then statement list else statement list end if; else statement list end if;
5
else-if ladder if condition then statement list elsif condition then statement list elsif condition then statement list else statement list end if;
6
case statement case when condition then statement list when condition then statement list else raise case_not_found; end case;
--optional
7
goto statement
… goto there;
…
goto outer;
8
Loop