我正在编写需要发送refcursor的程序。
以下是变量声明:
v_def_cycle_start_date date;
v_def_cycle_end_date date
根据某些条件,我们会在代码中计算v_def_cycle_start_date
和v_def_cycle_end_date
。我们最后使用它们。所以我想把它作为绑定变量传递给我。但是日期变量没有起作用。
open results for
'SELECT tt.bd_iid,tt.make_iid,tta.aux_entity_iid,tta.quantity
FROM txn_tab tt,txn_tab_amount tta,eli_txn r,
export_date pts,
WHERE tt.txn_tab_iid = tta.txn_tab_iid
AND tt.channel = 2
AND tt.txn_tab_iid = r.txn_tab_iid
AND r.elig = 1
AND EXISTS
(SELECT 1 FROM txn_eod t
WHERE tt.txn_eod_iid = t.txn_eod_iid
AND t.end_date BETWEEN nvl(pts.cycle_end_date,:v_def_cycle_start_date) +(1 / 86400) AND (:v_def_cycle_end_date))'
using v_def_cycle_start_date , v_def_cycle_end_date
请帮助解决这个问题?
答案 0 :(得分:0)
尝试这种替代方法。希望它有所帮助。
DECLARE
result sys_refcursor;
v_def_cycle_start_date DATE;
v_def_cycle_end_date DATE;
BEGIN
OPEN results FOR 'SELECT tt.bd_iid,tt.make_iid,tta.aux_entity_iid,tta.quantity
FROM txn_tab tt,txn_tab_amount tta,eli_txn r,
export_date pts,
WHERE tt.txn_tab_iid = tta.txn_tab_iid
AND tt.channel = 2
AND tt.txn_tab_iid = r.txn_tab_iid
AND r.elig = 1
AND EXISTS
(SELECT 1 FROM txn_eod t
WHERE tt.txn_eod_iid = t.txn_eod_iid
AND t.end_date BETWEEN nvl(pts.cycle_end_date,'||''''||v_def_cycle_start_date||''''||' +(1 / 86400)) AND ('||''''||v_def_cycle_end_date||''''||')';
END;