sql - Case statement within select case statement -
i trying create case
statement work seem messing syntax somehow. here have far:
select lp.assign_date, case when lp.assign_date > '01-jan-13' (select count(*) > 0 'bad' else 'good' end transaction_table account = :v_acct , transaction_date < :v_tran_date , transaction_code = :v_tran_code , :v_tran_code in (1,6,25) , attorney_id = :v_atty_id) else (select function_legal_chk(:v_acct, :v_tran_date) dual) legal_placement lp;
essentially checking see if assigned date after january, if next case statement
else function
.
here error receiving:
ora-00923: keyword not found expected 00923. 00000 - "from keyword not found expected"
from know , research i've done on case statements
, syntax seems correct not sure if case
within case
can done.
any appreciated.
here correct syntax:
select lp.assign_date, (case when lp.assign_date > '01-jan-13' (select (case when count(*) > 0 'bad' else 'good' end) transaction_table account = :v_acct , transaction_date < :v_tran_date , transaction_code = :v_tran_code , :v_tran_code in (1,6,25) , attorney_id = :v_atty_id ) else function_legal_chk(:v_acct, :v_tran_date) end) legal_placement lp;
the nested case
statement either has entirely in subquery (as shown above) or entirely outside. original has half-and-half. also, don't need subquery call function in select
. technically ok, unnecessary.
Comments
Post a Comment