Oracle's stored procedure is actually to execute a task, which includes a series of PLSQL statements stored in the database and becomes a database object. High Efficiency
Oracle's stored procedure is actually to execute a task, which includes a series of pl SQL statements stored in the database and becomes a database object. High Efficiency
The stored procedure of Oracle is actually to execute a task, which includes a series of pl SQL statements stored in the database and becomes an object of the database. The efficiency is relatively high, but when you create a stored procedure, it will make a judgment and compile. Just like C Programming, we first set the variables and the actions related to the variables, and assign values to the variables during compilation to get the final result.
Create a simple Stored Procedure named a_proc with empty content. The syntax of oracle stored procedures begins with "end", which reminds people of the pascal language they have learned. Null indicates a null value. Execute is used to execute the stored procedure. As shown in.
Or use another method for compilation and execution:
If you want to execute the stored procedure to display some information, you can use the output function DBMS_OUTPUT.PUT_LINE, which is somewhat similar to the print in C language. In addition, you need to use the set serveroutput on command to SET the environment variable serveroutput to the open state during compilation, so that the pl/SQL program can output the results in SQL * plus and SQL * plus, finally execute for compilation. As shown in, the final result is "hello ".
The above is just an example of a simple stored procedure. The following stored procedure involves calling a data table. Let's take a look at the specific process. The name is displayed when the ID is entered. The syntax is the same as above. First, set the output variable name to variable a_name, and the input variable ID to variable a_id, then, execute an SQL statement between begin and end to implement the condition, and use the output function to output the result. Shows the compilation status.