variable of PL/SQL programming

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.