You may want to check your query by using SQL*PLus to confirm there really is no data found (0 rows returned). Why? Because of your use of quotation marks in forming a string value.
Also, your query can be coded without the dynamic SQL. If you already know the table name, why bother with the dynamic SQL?
If it is the case where your query is structured properly AND there is no data to be returned, then you can wrap an IF-THEN-ELSE around your execute immediate. You can code it this way as well:
DECLARE
v_cnt NUMBER;
BEGIN
select count (*) into v_cnt
from dba_tab_columns
where data_type = 'LONG RAW'
and table_name = 'CUSTOM';
IF v_cnt > 0 THEN
dbms_output.put_line('There is long raw data in table CUSTOM');
ELSE
dbms_output.put_line('There is no long raw data in table CUSTOM');
END IF;
END;
You can also use exception handling, cursors, no data found, just to name a few other ways to do this.
Bookmarks