Set serveroutput on;
Scalar:
Declare v_name mytable. name % type;
Begin
Select name into V _ name from mytable where id = & AAAAA;
Dbms_output.put_line ('name: '| V _
Name );
Exception
When no_data_foundthen dbms_output.put_line ('no number ');
End;
Combination:
Declare type emp_record is record
-- Define the record type
(
Name EMP. name % type,
Salary EMP. Salary % Type
);
Myrecord emp_record; -- Define record Variables
Begin
Select name, salary into myrecord from mytable where id = 1;
Exception
When no_data_found then dbms_output.put_line ('no number ');
End;
Refer:
Declare type my_cursor is ref cursor;
Mycursor my_cursor;
V_name mytable. name % type;
Begin
Open mycursor for select name from mytable;
Loop
Fetch mycursor into name;
Exit when mycursor % notfound;
End loop;
Close mycursor;
Exception
When no_data_found then dbms_output.put_line ("no number ");
End;