1. What is a PL/SQL program
1、PL/SQL (Procedure Language/SQL)。
2. PLSQL is Oracle's procedural extension to the sql language.
Refers to the addition of procedural processing statements (such as branches, loops, etc.) in the SQL command language, so that the SQL language has procedural processing capabilities.
PL/SQL is an extension to the SQL language, and PL/SQL is a procedural language.
Two purposes of learning Oracle database PL/SQL
1. The most efficient operation of Oracle database.
2. Lay the foundation for learning stored procedures, stored functions, and triggers.
Three PL/SQL proposals
For example: according to the employee's title, the salary will be increased by 1,000 for the president, 800 for the manager, and 400 for the others.
To such an example can not be done with simple SQL statements, it must be done in a procedural language.
PL/SQL: Simple, efficient, flexible, practical.
SQL extensions for four different databases
Oracle:PL/SQL
DB2:SQL/PL
SQL Server:Transac-SQL(T-SQL)
Five of the simplest PL/SQL programs
1. Demand
print Hello World
2. Code
set serveroutput on
declare
--说明部分(变量,光标或者例外)
begin
--程序体
dbms_output.put_line('Hello World');
end;
/
3. Running results
Hello World
PL/SQL procedure completed successfully.
4. Pay attention
If you want to output information on the screen, you need to turn on the serveroutput switch
Six how to view the package
SQL> desc dbms_output
PROCEDURE DISABLE
PROCEDURE ENABLE
参数名称类型输入/输出默认值?
-------------------------------------------------------------------
BUFFER_SIZE NUMBER(38) IN DEFAULT
PROCEDURE GET_LINE
参数名称类型输入/输出默认值?
-------------------------------------------------------------------
LINE VARCHAR2 OUT
STATUS NUMBER(38) OUT
PROCEDURE GET_LINES
参数名称类型输入/输出默认值?
-------------------------------------------------------------------
LINES TABLE OF VARCHAR2(32767) OUT
NUMLINES NUMBER(38) IN/OUT
PROCEDURE GET_LINES
参数名称类型输入/输出默认值?
-------------------------------------------------------------------
LINES DBMSOUTPUT_LINESARRAY OUT
NUMLINES NUMBER(38) IN/OUT
PROCEDURE NEW_LINE
PROCEDURE PUT
参数名称类型输入/输出默认值?
-------------------------------------------------------------------
A VARCHAR2 IN
PROCEDURE PUT_LINE
参数名称类型输入/输出默认值?
-------------------------------------------------------------------
A VARCHAR2 IN
SQL>