2017-07-27 83 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