When we use BULK COLLECT, if a query does not fetch any records, it does not throw NO_DATA_FOUND exception. So, we need to check whether the collection variable has any elements or not.
Example:
- SQL> declare
- type emp_tab is table of emp%rowtype;
- t_emp emp_tab;
- begin
- select * bulk collect into t_emp from emp;
- IF t_emp.count = 0 THEN
- dbms_output.put_line(‘Bulk Collect: No Records in the Table’);
- ELSE
- dbms_output.put_line(t_emp.count)
- END IF;
- end;
- /
0 comments:
Post a Comment