The main content of this article is as follows:
Chapter 1 Introduction to PL/SQL programming
1.1 SQL and PL/SQL
1.1.1 what is PL/SQL?
1.2 advantages or features of PL/SQL
1.2.1 facilitating the running of client/server environment applications
1.2.2 applicable to customer Environments
1.2.3 procedural
1.2.4 Modularization
1.2.5 handling of running errors
1.2.6 provides a large number of built-in packages
1.3 PL/SQL available SQL statements
1.4 run the PL/SQL Program
SQL is only a language for accessing and operating databases. It is not a programming language with process control. Only a programming language can be used for application software development. PL/SQL is an advanced database programming language used to access Oracle databases in various environments. Since the language is integrated into the database server, PL/SQL code can process data quickly and efficiently. In addition, PL/SQL is also a feature of Oracle Database client tools. This chapter mainly discusses the necessity of introducing PL/SQL and the main features of this language, as well as the importance of PL/SQL and the database version. I also want to introduce some more detailed advanced concepts throughout the book, and at the end of this chapter I will explain some of the database tables we use in the case of this book.
1.1 SQL and PL/sql1.1.1 what is PL/SQL?
PL/SQL is the abbreviation of procedure language & Structured Query Language. Oracle SQL is a product that supports the ANSI (American National Standards Institute) and iso92 (International Standards Organization) standards. PL/SQL is an extension of the SQL stored procedure language. Since oracle6, Oracle RDBMS has attached PL/SQL. It is now a process processing language (PL/SQL. Currently, PL/SQL consists of two parts: the database engine and the independent engine that can be embedded into many products (such as C language and Java language. These two parts can be called: Database PL/SQL and tool PL/SQL. The two programming is very similar. All have programming structures, syntaxes, and logic mechanisms. The PL/SQL tool also adds syntaxes for supporting tools (such as Oracle Forms), such as setting buttons on the form. This chapter describes the database PL/SQL.
1.2 advantages or features of PL/SQL 1.2.1 is conducive to the running of applications in the customer/server environment
For the customer/server environment, the real bottleneck is the network. No matter how fast the network is, as long as the client and the server exchange a large amount of data. The efficiency of Application Operation is naturally affected. If PL/SQL is used for programming, put this type of application with a large amount of data processing on the server side for execution. Naturally, the data transmission time on the Internet is saved.
1.2.2 applicable to customer Environments
PL/SQL is divided into PL/SQL databases and PL/SQL tools. For the client, PL/SQL can be nested into the corresponding tools, and the client program can execute the local PL/SQL section, you can also send SQL commands to the service or activate the PL/SQL program running on the server.
1.2.3 procedural
PL/SQL is a procedural extension of Oracle in standard SQL. It not only allows SQL statements to be embedded in PL/SQL programs, but also allows various types of conditional branch statements and cyclic statements, multiple applications can share their solutions.
1.2.4 Modularization
The PL/SQL program structure is a descriptive and well-defined block structure and nested block structure. It is divided into separate processes, functions, and triggers and can be combined into packages, improve the modularization of the program.
1.2.5 handling of running errors
With exceptions provided by PL/SQL, developers can centrally handle various Oracle and PL/SQL errors, or handle system and custom errors, to enhance Application robustness.
1.2.6 provides a large number of built-in packages
Oracle provides a large number of built-in packages. These packages can be used to implement some underlying operations and advanced functions of DBS, which play an important role for DBA and application developers.
Of course, there are other advantages such as better performance, portability and compatibility, maintainability, ease of use and quickness.
1.3 PL/SQL available SQL statements
PL/SQL is the core language of the Oracle system. Currently, many components of Oracle are written by PL/SQL. The following SQL statements can be used in PL/SQL:
Insert, update, delete, select into, commit, rollback, savepoint.
Tip: only the DML part in the SQL statement can be used in PL/SQL, but not the DDL part. If you want to use DDL (such as create table) in PL/SQL, it can only be used dynamically.
L the PL/SQL Component of Oracle checks the names, column names, and Data Types of tables used by PL/SQL programs.
L PL/SQL can be used in SQL * Plus.
L PL/SQL can be used in advanced languages.
L PL/SQL can be used in Oracle development tools (such as SQL developer or procedure builder ).
L other development tools can also call PL/SQL compiling processes and functions, such as Power Builder, to call PL/SQL processes on the server.
1.4 run the PL/SQL Program
PL/SQL programs run through an oracle engine. This engine may be on the Oracle server or the Oracle Application Development client. The engine executes procedural statements in PL/SQL and sends the SQL statements to the database server for execution. Return the result to the execution end.