--Process statements
SELECT * from Wan3;
--three-segment first-write fixed structure declare begin end
Declare
A VARCHAR2 (6): = ' ere ';
Begin
DELETE from Wan3 WHERE ename=a;
End
--
DECLARE
V_deptno number;
V_dname VARCHAR2 (100);
BEGIN
INSERT into WAN3
VALUES
(' hFE ', 15,5411,sysdate,null,null);
END;
--Conditional statement if case
--Pay attention to the type problem of variable naming
Declare
V_ename VARCHAR2 (6);
V_sal Wan3.sal%type; --can be used with a known type of keyword%
Begin
Select name into V_ename from wan3 where name= ' JH ';
Dbms_output.put_line (' The name of the output is: ' | | V_ename);
Select Sal into V_sal from Wan3 where age=30;
--Fixed format output connection with | |
Dbms_output.put_line (v_ename| | ' The wages are: ' | | V_sal);
--if usage
If V_sal <7000 Then
Dbms_output.put_line (v_ename| | ' Wages are less than 8000 ');
Else
Dbms_output.put_line (v_ename| | ' The salary is. Own better: ' | | V_sal);
End If;
End;
----Conditional Statement Case
Declare
V_sal number: = 3000;
A varchar2 (50);
Begin
--Assigning a value to variable A is a case expression
A: =
Case V_sal
When the "My salary is 5000"
When 4500 and then ' my salary is 4500 '
Else ' Without your wages '
End
Dbms_output.put_line (' See is not one:: ' | | a);
End;
--loop statement loop exit when it is necessary to exit the loop
Declare
A number (3): = 0; --declaring variables and assigning values
Begin
Loop--Loop start position
A: =a+2;
The current value of Dbms_output.put_line (' A ' is: ' | | a);
Exit when a=10; --Cyclic exit conditions
End Loop; --End of cycle
End
--while Cycle
Declare
A number (5);
Begin
Select Sal into a from wan3 where age=30;
Dbms_output.put_line (a);
While a<10000--when the condition is true
Loop
The value of Dbms_output.put_line (' A is: ' | | a);
a:=a+500;
End Loop;
End
--for Loop Statements
Declare
A number (5);
Begin
For a in reverse 1..3 loop--for loop counter in lower bound: Upper Limit ascending (decrease if join reverse)
INSERT into WAN3 values (' 85fe ', 15,5411,sysdate,null,null); --Inserting data
End Loop;
End
SELECT * from WAN;
Delete from wan3 where age=15;
--Delete multiple columns at the same time
ALTER TABLE WAN3 drop (kjj,age);
--Rename Columns
ALTER TABLE wan3 Rename column sal to salll
--Rename the table name
Rename Wan3 to Wan
Oracle Procedure Statements