Stored Procedure: a collection of SQL and PL/SQL statements. I think it is similar to the Java method.
1. Examples of the creation process:
Create or replace procedure mypro (did in varchar2) -- create a stored procedure
Is
Name varchar2 (10); -- the variable declaration here must contain the length
Begin
Select dname into name from dept where did = did;
Dbms_output.put_line (name );
End;
/
Insert a custom process to a table
Declare
Age number; -- defines the variables to be used in the insert operation.
Id varchar2 (10 );
Name varchar2 (10 );
Begin
Age: = 1;
While age <= 10 loop -- judgment Condition
Id: = 'id' | age;
Name: = 'name' | age;
Insert into dept values (id, name, age); -- insert statement
Dbms_output.put_line (age );
Age: = age + 1;
End loop;
End;
/
Use process insert. Custom parameter passing
Create or replace procedure aa (age number, name varchar2)
Is
Begin
Select dname into name from dept d where dage = age; -- Query and assign values using the passed parameters
End;
/
Declare
Age number;
Name varchar2 (10 );
Begin
Age: = 1
Aa (age, name );
Dbms_output.put_line (name );
End;
/
SQL plus can be used for execution, but the following error occurs when plsql is used: I don't know why,
If you have read the BLOG, you can reply to me. Thank you.
Author: zhang6622056