我想在做个案判决后做一个选择
即
select x from dual ( x is actually a variable in a report writer tool)
case when x = 'equipment'
select * from inside_sales
else
select * from outside_sales
end
无法使用PL / SQL
任何帮助将不胜感激
答案 0 :(得分:3)
我想你想要这个:
select * from inside_sales where x = 'equipment'
union all
select * from outside_sales where x <> 'equipment';
注意:如果x
可以是NULL
,则第二个条件稍微复杂一些。
答案 1 :(得分:0)
像这样的东西。但是如何处理检索到的数据?
create function sales_report (is_x IN varchar2)
return // what to return?
is
row_i_s inside_sales%rowtype;
row_o_s ouside_sales%rowtype;
begin
case is_x
when 'equipment'
then
select *
into row_i_s
from inside_sales;
else
select *
into row_o_s
from outside_sales;
end;
return // what to return?
end;