Hello,
I have table as shown below:
SQL> select * from mydata;
MAIN COMP
---------- ------------------
sales mycorporation.com
training
delivery
marketing mycorporation.com
I would like to define variables depending on the result of my select statement. The idea is something like this:
v_result should print 'main.comp' if comp is not null
v_result should print 'main.none' if comp is null
The idea I have is something like below, but I know it's is not right. Can you help me figure out the right way?
Thanks a lot!
declare
v_main varchar2(50);
v_comp varchar2(50);
BEGIN
select main into v_main from mydata;
select comp into v_comp from mydata;
case when (v_comp is not null) then
v_result := v_main||'.'||v_comp;
else
v_result := v_main||'.none';
end;
dbms_output.Put_line(v_result);
end;