Hi All,
I Have created stored proc where I am passing a parameter value which needs to be appended to the end of the table and executed, this is for a crystal reports application. Another value is passed as a parameter for the where clause.
It compiled fine, but it throws error when trying to access the data. Please suggest me any changes to fix it.
Thanks in advance!!
I Have created stored proc where I am passing a parameter value which needs to be appended to the end of the table and executed, this is for a crystal reports application. Another value is passed as a parameter for the where clause.
It compiled fine, but it throws error when trying to access the data. Please suggest me any changes to fix it.
Code:
CREATE OR REPLACE PROCEDURE gp_realloc (p_eod_date IN VARCHAR2,
p_link IN NUMBER,
c_rec IN OUT SYS_REFCURSOR)
IS
l_str VARCHAR2 (4000);
BEGIN
l_str :=
'SELECT DISTINCT r_t_s.trade_link_num trade_link_num,
pos_sum.trade_num trade_num,
ROUND (pos_sum.market_price / NVL (mass_conv_factor, 1.0), 8)
market_price,
ROUND (pos_sum.trade_price / NVL (mass_conv_factor, 1.0), 8)
trade_price,
m_c_d.price_curve_type_cd
FROM pos_sum_m_'
|| p_eod_date
|| 'pos_sum
LEFT OUTER JOIN
r_t_s
ON pos_sum.trade_num = r_t_s.trade_num
AND pos_sum.term_num = r_t_s.term_num
AND r_t_s.record_type_ind = 0
AND ( pos_sum.data_source_cd = ''SYSTEM-STORAGE''
OR r_t_s.internal_ind = 0
OR (r_t_s.internal_ind = 1
AND (pos_sum.buy_sell_ind = r_t_s.buy_sell_ind)))
LEFT OUTER JOIN m_c_d
ON pos_sum.mtm_quote_def_num = m_c_d.curve_num
JOIN org_strategy ON pos_sum.strategy_num = org_strategy.strategy_num
WHERE pos_sum.mkt_snapshot_cd = ''Official''
AND r_t_s.trade_link_num :p_link
AND pos_sum.bifurcation_ind IN (0, 2)
--AND pos_sum.trade_num = 148094
AND pos_sum.time_period_type_ind = 4
AND pos_sum.risk_start_dt >= TO_DATE (''20110501000000'', ''YYYYMMDDHH24MISS'')
AND pos_sum.external_ref IS NULL';
OPEN c_rec FOR l_str;
END gp_realloc;
/
Thanks in advance!!