Hello all


Getting a complile error, when i try and use the following decode statement within a cursor for loop.

I cant compile as the pkg does not like the select statement within the decode statement,

Is the decode statement restricting the ability to perform a select statement within it?

Anybody else encounter this problem or know of a way round in when using the decode statement?

Thanks in advance



This is the simplified code:

For C_cursor in r_curosr

INSERT INTO SALES_LEDGER (
LAST_UPDATE_DATE, /
LAST_UPDATED_BY,
LAST_UPDATE_LOGIN,
TRANSACTION_ID,
GROUP_ID,
SPREAD_FLAG,
TRANSACTION_REASON,
DERIVED_PROCESS_FLAG,
quantity,
total_value_order,
reporting_date

)
VALUES (

SYSDATE,
SYSDATE
g_user_id,
SYSDATE,
g_user_id,
g_login_id,
LEDGER_S1.NEXTVAL,
l_group_id,
r_cursor.SPREAD_FLAG,
'Scheduled Change',
'N',
l_sum_qty,
l_total_val,
decode(l_date_flag, 'Y',last_day(add_months(sysdate, -1)),'E',
(select date_requested_current from
so_headers_all where header_id= r_cursor.HEADER_ID),sysdate)

);
END Loop;


This is the error, i cant compile as the pkg does not like the select statement within the decode statement

(1):PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
(1):
(1): ( - + mod not null others
(1): avg
(1): count current exists max min prior sql stddev sum variance
(1): execute forall time timestamp interval date
(1):

(1):

(2):PLS-00103: Encountered the symbol "," when expecting one of the following:
(2):
(2): ; return returning and or