1. Variables and Constants
Variable syntax: variable_name data_type [[Not NULL] [: =value]
Description: NOT NULL defines a non-null constraint on a variable, a variable must be assigned a non-null initial value, and its value is not allowed to be modified to null at any time.
--Examples of variables:
Sql>serverout onsql>declare v_num Number (4); BEGIN v_num:=20; Dbms_output. The value of put_line (' variable name v_num is: ' | | V_num); END; /
Constant syntax: Constant_name constant Data_type [: =value]
--Examples of constants:
DECLARE c_num CONSTANT Number (4): = 100; BEGIN Dbms_output. The value of Put_Line (' Constant name c_num: ' | | C_num); END;
2. Composite data type
2.1%type Type
The type of a column that references a variable or database is used as the data type of a variable.
SET serverout ondeclare v_ename scott.emp.ename%type; V_sal1 number (11); V_sal2 V_sal1%type; BEGIN SELECT ename,sal to V_ename,v_sal1 from Scott.emp WHERE empno=7369; V_sal2:=v_sal1; Dbms_output. Put_Line (v_ename| | ' The wages are ' | | V_SAL2); END
2.2%rowtype
Refers to a row in a database table as the data type, that is, the record type, which is the additional type of PL/SQL. Represents a record, equivalent to an object in Java. You can use the "." To access the properties in the record.
This article from "It Technology Learning and communication" blog, declined reprint!
PL/SQL data type