2017-07-27 76 views
-7

我想以后我做的情况下statment做一个选择不甲骨文的PL/SQL

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

这将有助于如果你能告诉一些示例数据和您想要的结果 – Phil

回答

3

我想你想要这样的:

select * from inside_sales where x = 'equipment' 
union all 
select * from outside_sales where x <> 'equipment'; 

注意:如果x可以是NULL,则第二种情况会稍微复杂一些。

+0

'when'似乎不正确的,当很多没有'CASE' – Phil

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; 
+0

嘿感谢,我将只可以将报表作家,写的东西否则 – DontKnow

+0

我没有得到你。请exaplin。 – fg78nc