DECLARE
v_exists number;
BEGIN
select count(*) into v_exists
from dba_tablespaces
where tablespace_name = 'TOOLS';
IF v_exists > 0 THEN
dbms_output.put_line('tablespace exists');
ELSE
dbms_output.put_line('tablespace does not exist');
END IF;
END;
Code:SQL> DECLARE 2 v_exists number; 3 BEGIN 4 select count(*) into v_exists 5 from dba_tablespaces 6 where tablespace_name = 'TOOLS'; 7 IF v_exists > 0 THEN 8 dbms_output.put_line('tablespace exists'); 9 ELSE 10 dbms_output.put_line('tablespace does not exist'); 11 END IF; 12 END; 13 / tablespace exists PL/SQL procedure successfully completed. 1 DECLARE 2 v_exists number; 3 BEGIN 4 select count(*) into v_exists 5 from dba_tablespaces 6 where tablespace_name = 'TOOLSSS'; 7 IF v_exists > 0 THEN 8 dbms_output.put_line('tablespace exists'); 9 ELSE 10 dbms_output.put_line('tablespace does not exist'); 11 END IF; 12* END; SQL> / tablespace does not exist PL/SQL procedure successfully completed.




Reply With Quote