2 Replies Latest reply on Nov 9, 2012 3:19 PM by 742139

    SQLPLUS - then /else run script.sql

      I am having trouble with the script below, would anyone have any suggestions or be able to help me out?

      I am trying to do a case statement where I select to see if an ID exists or not and if it doesnt i want to run a .sql file but its not working properly.

      select case when exists (select ID from VERSION where ID = '16.1')
      then 'ID Exists'
      else @script.sql
      from dual;

      Its not allowing me to run the @script.sql with the else statement...does anyone have any suggestions?

        • 1. Re: SQLPLUS - then /else run script.sql
          Frank Kulash

          Welcome to the forum!

          Post your question in only one forum; that way, you'll only have to look for answers in one place. Since there are already answers for your question in the SQL forum {message:id=10680342} , you should mark this thread as "Answered" right away, and continue in that other thread.
          • 2. Re: SQLPLUS - then /else run script.sql
            create script prompt.sql :
            PROMPT &1

            in your main script:

            define column script_name new_value script_name noprint

            select case when exists(seelct ID from VERSIOn where id = '16.1')
            then 'prompt.sql "ID Exists"'
            else 'script.sql'
            end as script_name
            from dual;


            Best regards