Why learn PL/SQL

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
  1. set serveroutput on
  2. declare
  3. --说明部分(变量,光标或者例外)
  4. begin
  5. --程序体
  6. dbms_output.put_line('Hello World');
  7. end;
  8. /
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

 

  1. SQL> desc dbms_output
  2. PROCEDURE DISABLE
  3. PROCEDURE ENABLE
  4. 参数名称类型输入/输出默认值?
  5. -------------------------------------------------------------------
  6. BUFFER_SIZE NUMBER(38) IN DEFAULT
  7. PROCEDURE GET_LINE
  8. 参数名称类型输入/输出默认值?
  9. -------------------------------------------------------------------
  10. LINE VARCHAR2 OUT
  11. STATUS NUMBER(38) OUT
  12. PROCEDURE GET_LINES
  13. 参数名称类型输入/输出默认值?
  14. -------------------------------------------------------------------
  15. LINES TABLE OF VARCHAR2(32767) OUT
  16. NUMLINES NUMBER(38) IN/OUT
  17. PROCEDURE GET_LINES
  18. 参数名称类型输入/输出默认值?
  19. -------------------------------------------------------------------
  20. LINES DBMSOUTPUT_LINESARRAY OUT
  21. NUMLINES NUMBER(38) IN/OUT
  22. PROCEDURE NEW_LINE
  23. PROCEDURE PUT
  24. 参数名称类型输入/输出默认值?
  25. -------------------------------------------------------------------
  26. A VARCHAR2 IN
  27. PROCEDURE PUT_LINE
  28. 参数名称类型输入/输出默认值?
  29. -------------------------------------------------------------------
  30. A VARCHAR2 IN
  31. SQL>
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326195190&siteId=291194637