ORACLE variable definition

Source: Internet
Author: User

 1 DECLARE   2V_productid Productinfo.productid%TYPE;3V_productnameVARCHAR2( -); 4V_productprice Number(8,2); 5V_quantity Number(Ten); 6V_desperation CONSTANT V_productname%TYPE:='Test'; 7         8V_spitgr Simple_integer:= 99.9; 9V_longLONG:='Long Type Test';TenV_date DATS:=sysdate; One BEGIN A     SELECTproductid,productname,productprice,quantity -      intov_productid,v_productname,v_productprice,v_quantity -      fromProductInfo the     WHEREPro= '0240040001'; -      -Dbms_output. Put_Line ('V_productid ='       ||V_productid); -Dbms_output. Put_Line ('V_productname ='     ||V_productname +                              ||    'length ='||LENGTH (V_productname)); -Dbms_output. Put_Line ('V_productprice ='    ||v_productprice); +Dbms_output. Put_Line ('v_quantity ='        ||v_quantity); ADbms_output. Put_Line ('v_desperation ='     ||v_desperation); atDbms_output. Put_Line ('V_spitgr ='          ||v_spitgr); -Dbms_output. Put_Line ('V_long ='           ||V_long); -Dbms_output. Put_Line ('v_date ='           ||v_date); - END;

"Code parsing"

The declaration part of the statement block is in the right-justified way

Line 2nd declares a variable using the%type method, which indicates that the type of the variable V_productid is the same as the ProductID field data type in table ProductInfo

Line 3rd indicates that the data type is a VARCHAR2 type of length 20

4th ~ 5 rows are different ways of using number type

Line 6th uses%type to reference the data type of v_productname and declares a constant

The initial value of line 8th is 99.9, but since the data type can only represent integers, the value of the variable v_spitgr should be 100

11th ~ 26 Lines belong to the Executive Body part

Rows 12th to 15 indicate that data is queried from the product table and stored in a variable

The 17th ~ 25 row represents the output to the screen, which verifies that the variable stores the data

ORACLE variable definition

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.