[Oracle] PLSQL 動態SQL寫法
可否有板友知道我這樣的需求是否可以達成? 謝謝
只是想求證一下然後開始coding...我的需求如下
說明:
當開關=OFF時 , 則只選擇小的表格
當開關=ON 時 , 則選擇小表格 union all 大表格
--建立開關表格
create table TEST.switch (A varchar(10));
insert into TEST.switch values ('ON');
commit;
虛擬碼:
--以下是否要用跳脫字元宣告?
string a = '2013-05-01' and date >='2013-01-01';
FUNCTION ( string a )
{
if (開關 = 'ON' )
then select * from TEST.TAB where $string union all (select * from TEST.TAB_PARTED where $string );
fi
else if (開關 = 'OFF' )
則 select * from TEST.TAB where $string;
elfi
}
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.61.165.56
→
07/01 23:20, , 1F
07/01 23:20, 1F
→
07/01 23:20, , 2F
07/01 23:20, 2F
→
07/01 23:21, , 3F
07/01 23:21, 3F
→
07/01 23:21, , 4F
07/01 23:21, 4F
→
07/03 23:53, , 5F
07/03 23:53, 5F