For PL/SQL programming, this part of the Oracle database storage process is accurate, alas, it was difficult to learn when I was learning. In fact, it is very simple, is to learn a few times, learn not to learn again. Slowly, you can take care of it.
The experience has been taught. Here's a look at the Plsql variables related knowledge:
Let's take a look at the following code:
Declare
V_num number (20);
Begin
Dbms_output.put_line (' Please output: ' | | V_num);
End
/
What do you think the result will be?
Yes, there is no result. Very simple, where v_num is the variable, and now the variable is not assigned!
Take another look at the code:
Declare
V_num Number (20): = 100;
Begin
Dbms_output.put_line (' Please output: ' | | V_num);
End
/
The result is: 100
Take another look at the code:
Declare
V_NUM constant Number (a) not null:=100;
Begin
v_num:=20;
Dbms_output.put_line (' Please output: ' | | V_num);
End
/
The result: syntax error
Why is it? Note: Constant indicates that the variable is a constant. Since it is a constant, it is immutable!
Take another look at the code:
Declare
V_eno Emp.empno%type;
V_ename Emp.ename%type;
Begin
v_eno:=&empno;
Select Ename to V_ename from EMP where Empno=v_eno;
Dbms_output.put_line (' Numbered ' | | v_eno| | ' The name of the employee is: ' | | V_ename);
End
/
This is the use of type types.
Take another look at the code:
Declare
V_deptrow Dept%rowtype;
Begin
SELECT * into V_deptrow from dept where deptno=10;
Dbms_output.put_line (v_deptrow.dname| | ' ' | | V_DEPTROW.LOC);
End
/
The above is the use of deptrow.
The above-mentioned part of the variable is simply too simple, and here it is. If you don't understand this, Oracle won't have to learn anymore.
This article is from the "Brother Hong Linux World" blog, so be sure to keep this source http://zhengkangkang.blog.51cto.com/12015643/1949512
variable of PL/SQL programming