use of insert in case
874449Aug 24 2011 — edited Aug 25 2011Hi,
Is it possible to use insert statement in CASE.
For example as follows:
let create a table as
create table DECOMPENSATED_BALANCE_TMP (ENDING_ENTERED_BALANCE_DR number, ENDING_ENTERED_BALANCE_CR number);
select
CASE
WHEN (PERIOD_NET_DR+BEGIN_BALANCE_DR-PERIOD_NET_CR-BEGIN_BALANCE_CR) total > 0
THEN
INSERT INTO XXGL_DECOMPENSATED_BALANCE_TMP (ENDING_ENTERED_BALANCE_DR) values (total)
WHEN (PERIOD_NET_DR+BEGIN_BALANCE_DR-PERIOD_NET_CR-BEGIN_BALANCE_CR) <= 0
THEN
INSERT INTO XXGL_DECOMPENSATED_BALANCE_TMP (ENDING_ENTERED_BALANCE_CR) values (total)
else
NULL
end
from gl_balances
where code_combination_id=109940 and currency_code='GBP';
Any answers will be highly appreciated ....
Thanks,
zaheer