What pl/SQL must understand:
1. process, function, trigger is pl/SQL programming
2. process, function, and trigger are in Oracle
3. pl/SQL is a very powerful database process Language
4. process. functions can be called in java programs.
----------------------------------------------------------
I will not talk about the advantages of pl/SQL.
Disadvantages:
Poor portability
----------------------------------------------------------
1. Write a stored procedure that can add records to a table
Created procedure process name is
Begin
Insert into table name values (Field 1, Field 2)
End;
Created or replace procedure process name is
Begin
Insert into table name values (Field 1, Field 2)
End
Replace indicates that if this exists, replace it.
View error information
Show error;
----------------------------------------------------------
Block Structure
A pl/SQL block consists of three parts: definition, execution, and exception,
As follows:
Declear
/* Definition section ------- define constants, variables, cursors, exceptions, and complex data types */
Begin
/* Execution part --- the pl/SQL statements to be executed and SQL statements */
Exception
/* Exception Handling Section ----- handle various running errors */
End;
Note:
The definition starts with declare,
This part is optional
The execution part starts from begin.
This part is required
The exception starts with exception.
This part is optional
---------------------------------------------------------
How to call this process
1. exec process name (parameter 1, parameter 2 ...);
2. call process name (parameter 1, parameter 2 ...);
----------------------------------------------------------
Oracle coding specifications
1. Notes:
Single line comment --
Multi-line comment /*.....*/
2. Identity symbol naming rules
1) when defining a variable, we recommend that you use v _ as the prefix v_sal.
2) when defining a constant, we recommend that you use c _ as the prefix c_rate.
3) when defining a cursor, we recommend using _ cursor as the suffix emp_cursor;
4) when defining an exception, we recommend that you use e _ as the prefix e_error;
----------------------------------------------------------