I am doing a select count(*) into v_cnt where ****;
in my PL/SQL program and I am getting a no data found error. I thought that if you are doing a count it would be zero or greater than zero. How would I get a no data found error?
Printable View
I am doing a select count(*) into v_cnt where ****;
in my PL/SQL program and I am getting a no data found error. I thought that if you are doing a count it would be zero or greater than zero. How would I get a no data found error?
Hi lesstjm,
Are you sure you got the error because of this statement?
COUNT function never returns null, that's true. Maybe you better debug you pl/sql program.
Could you provide us with the whole text of your block?
Hi
True I tried out a small pl/sql block about the above subject and I never got any errors like no_data_foudn here is the pl/sql block I checked with
declare
a number(4);
begin
select count(*) into a from emp;
dbms_output.put_line('Record count : ' || a);
end;
it returned me zero when there were no record in the above table
Regards
This error is obviously a user defined exception which is being raised when you run the PL/SQl.
You would have something like this in your code in that case...:
IF v_count = 0 THEN
raise_application_error(-20102, 'No Data Found');
END IF;