The variable for PL/sql:
Variable type:
1. Common simple variable types built into the system: for example, most database tables have field types that can be used as variable types;
2. User-defined complex variable types: such as record type;
3. Reference type: A pointer value was saved;
4. Large object Type (LOB): An address to a large object is saved;
syntax: identifier [CONSTANT] datatype [not NULL] [: = | DEFAULT expr];
Description:
1. Variable naming recommendations follow general rules, such as V_name, which represents a variable, and c_name represents a constant;
2. It is generally recommended that each line declare a variable, so that the program is more readable;
3. If a variable is declared but not initialized, the value of the variable is null before it is assigned; A good programming habit is to initialize all declared variables to the assigned value;
4. In the same block, avoid naming variables that are the same as the field names in the database table.
Example of a variable declaration of a general type:
1. Scalar data types
Prior to building a table, you learned the data types of Oracle SQL, which not only supports these data types, but also their own data types. Such as:
2. Attribute data type
When declaring a variable's value as a row of a database or a column of a database, you can declare it directly using the property type. Oracle has two types of property data:%type and%rowtype
%rowtype: reference in a database table One line as a data type, you can use the. "To access the properties in the record.
Instance:
%TYPE
The type of the column that references a variable or database as the data type of a variable, identifier Table.column_name%type;
Instance:
bindable variables (bind Variable also known as host Variable, non-plsql variables):
A bindable variable is a variable defined in a shrinking master environment that generally indicates the Sqlplus execution environment or the Command Window execution environment for Plsql Developer, which can be used to pass values to Plsql at run time, creating syntax: VARIABLE return_code number VARIABLE return_msg VARCHAR2 (30) It is noted that the definition of variables in the standard plsql is not possible with the VARIABLE keyword, This keyword is only valid in the Sqlplus execution environment and can be used to output variable content using the print statement. When using this variable in plsql, the preceding ":" is used to differentiate.
variable of PL/SQL