InProgramWhen defining variables, constants, and parameters, you must specify the PL/SQL data type for them. When compiling PL/SQL programs, you can use the scalar type, composite type, reference type, and lob (large
Object.
The most common scalar variable in PL/SQL is a scalar variable. when defining a scalar variable, you must specify the title data type. The title data types generally include: Numbers, characters, and dates, boolean type. Each type contains the corresponding subclass. For example, the number type contains sub-types such as integer and positive.
I. Common scalar types
1. varchar2 (N)
2. Char (N)
3. Number (P, S)
4. Date
5. Timestamp
This data type is added when 9i is used to define date and time data. The method used to assign values to the date variable is the same as that used to assign values to the date variable. However, when displayed, it not only displays the date, but also the time and the last afternoon Mark.
6. Long and long
Raw
7. Boolean
8. binary_integer
9. binary_float
Binary double and binary double are not many new types of oracle10.
Ii. Use scalar Variables
Variable assignment in PL/SQL is different from otherProgramming Language, You must add a colon (: =) before the equal sign ).
Eg:
Declare
X number;
Y number;
-- 7: Number of output digits. 3 is rounded to three digits (positive: three digits on the right of the decimal point, negative: three digits on the left of the decimal point)
Z number (7,3 );
Codeid
Number;
Begin
X: = 200.0088;
Y: = x + 10;
Z: = 1000.0088;
Dbms_output.put_line (X );
Dbms_output.put_line ('y = '| y );
Dbms_output.put_line ('z = '| z );
-- Assign a value to the variable codeid
Select sum (user_id)
Into codeid from hr_employee hr;
Dbms_output.put_line ('codeid = '| codeid );
Codeid: = codeid * 100;
Dbms_output.put_line ('codeid = '| codeid );
End;
The output is as follows:
X = 200.0088
Y = 210.0088
* Z = 1000.009
Codeid = 1045
Codeid = 104500