Pl programming data types: 1. scalar 2. composite 3. reference 4.lob( largeobject )--------------
Pl programming data types: 1. scalar 2. composite 3. reference 4.lob( large object )--------------
Pl programming data types:
1. scalar)
2. composite)
3. reference)
4. lob (large object)
----------------------------------------------------------
Case of defining scalar
1. Define a variable-length string
V_ename varchar2 (10)
2. Define a decimal range-9999.99 to 9999.99
V_sal number (6, 2)
3. Define a decimal number and assign a value of 5.4: = to pl/SQL.
V_sal2 number (6, 2): = 5.4
4. Define a date type data
V_hiredate date;
5. Define a Boolean variable. The value cannot be blank. The initial value is false.
V_valid boolean not null default false;
----------------------------------------------------------
Compound variable
Variable used to store multiple values
1. pl/SQL records
2. pl/SQL table
3. nested tables
4. varray
----------------------------------------------------------
Reference variable
Divided into: cursor variable and object variable
Case 1
Use pl/SQL to write a block. You can enter the Department number and display all
Declare
-- Define a cursor type
Type chenchuang_emp_cursor is ref cursor;
-- Define a cursor variable
Test_cursor chenchuang_emp_cursor
-- Define variables
V_ename emp. name % type
V_sal emp. sal % type
Begin
-- Execute
-- Combines test_cursor with a select statement
Open testr_cursor for select ename, sal from emp where
Deptno = & no;
-- Cyclically retrieve
Loop
Fetch test_cursor into v_ename, v_sal;
-- Judge whether testr_cursor is null
Exit when testr_cursor % notfound;
Dbms_output.put_line ('name' | v_name | 'wage '| v_sal );
End loop;
End;