Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

IF statement in SQL*Plus - how to do it

848959Apr 6 2013 — edited Apr 6 2013
Hi,

In SQL*Plus script, I would like to keep conditional checking (IF statement) and proceed. For example, whatever is done in PL/SQL block below, want to do the same in SQL*Plus script, I know partly it can be done using VARIABLE keyword, conditional checking can be done using DECODE in SELECT statement, but I want to carry out a more complex requirement, hence I want to use IF statement somehow in SQL*Plus.

Another question, how to do spooling in PL/SQL script, it can be done using UTL_FILE, any other option is there to achieve this.

declare
v_ind_count int;
begin

select count(1) into v_ind_count from user_indexes where index_name = 'index_object_name';

IF v_ind_count > 0
THEN
dbms_output.put_line('index found');
ELSE
dbms_output.put_line('index does not exist');
END IF;
end;
/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 4 2013
Added on Apr 6 2013
3 comments
468 views