Link to home
Start Free TrialLog in
Avatar of fpkeegan
fpkeegan

asked on

oracle script defaulting a variable

How is s SQL script variable tested for not being defined and if not defined  set a default value.

A very simple example to describe the issue.  In the third input example I want the missing &3 to default to *. The real problem is much more complicated, this simply defineds the issue.

@test_script T_user kee *
@test_script T_user kee user_id
@test_script T_user kee

--------------------------------------------
-- test_script.sql
define col_name=&3
select &col_name from &1  where user_id like '%&2%';

----------------------------------------------

what I would like to have happen

if &3 is null then
     define col_name=*
else
   define col_name=&3
end if;

select &col_name from &1  where user_id like '%&2%';
ASKER CERTIFIED SOLUTION
Avatar of johnsone
johnsone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial