PL/SQL Programming   «Prev 

PL/SQL Variables

The standard Procedural Language (PL) for Structured Query Language (SQL, pronounced sequel) is referred to as PL/SQL.
PL/SQL is an imperative 3GL that was designed specifically for the seamless processing of SQL commands. It provides specific syntax for this purpose and supports exactly the same datatypes as SQL. Server-side PL/SQL is stored and compiled in Oracle Database and runs within the Oracle executable. It automatically inherits the robustness, security, and portability of Oracle Database.

What is PL/SQL?

It is the procedural (and sometimes object-oriented) programming extension to SQL, provided by Oracle, exclusively for Oracle. If you are familiar with another programming language called Ada, you will find striking similarities in PL/SQL. The reason they are so similar is that PL/SQL grew from Ada, borrowing many of its concepts from it. The PL in PL/SQL stands for procedural language. PL/SQL is a proprietary language not available outside the Oracle Database. It is a third-generation language (3GL) that provides programming constructs similar to other 3GL languages, including variable declarations, loops, error handling.
Historically, PL/SQL was procedural only. PL/SQL can now be considered part of the object-oriented category of languages. Should we change the name to PL/OO/SQL?
Answer: No.

Variable declaration can be on any type, native to Oracle such as NUMBER, CHAR AND DATE, or native to PL/SQL such as BOOLEAN.

You can initialize a variable while you declare it in PL/SQL

Values can be assigned to a variable in two ways. 1) The first way is to use an assignment operator ':=', with the variable on the left-hand side and an expression including literals, variables, and algebraic operators, or PL/SQL function calls on the right.

The second way to assign values to variables is to SELECT and FETCH database values into Variables