Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 can i use a function in case statement

Author  Topic 

dasu
Posting Yak Master

104 Posts

Posted - 2004-10-13 : 09:14:57
please suggest me the solution
can i use function in case statement



UPDATE a
SET a.stat_cd =dbo.fn_cbs_rqst_err(),
a.rsn_tx =b.err_cd,
a.upd_job_id =18
FROM T_CBS_RQST_DTLS a , T_CBS_EPIERR b
WHERE cast (b.acct_no as int)=a.acct_no
and b.val_dt=a.val_dt
and a.rqst_cd=
( SELECT CASE upd_actn_fl

WHEN DBO.FN_CBS_UPD_PSTN() THEN dbo.fn_cbs_pstn()
WHEN DBO.FN_CBS_UPD_TRN() THEN dbo.fn_cbs_trn()
END
)

regards
dasu.g

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-10-13 : 09:20:36
you can, but your example

WHEN DBO.FN_CBS_UPD_PSTN() THEN dbo.fn_cbs_pstn()
WHEN DBO.FN_CBS_UPD_TRN() THEN dbo.fn_cbs_trn()

implies the following
--that dbo.fn_cbs_upd_pstn will return (true or false aka 1 or 0)
--that dbo.fn_cbs_upd_trn will return (true or false aka 1 or 0)
--that if dbo.fn_cbs_upd_pstn returns 1 then upd_actn_fl = 1
--that if dbo.fn_cbs_upd_pstn returns 0 and dbo.fn_cbs_upd_trn returns 1 then upd_actn_fl = 1
--that if both functions return 0 then return ?? (no else)

I would also have to question where the parameters of the functions went? As is, the would always return the same value??




Corey
Go to Top of Page
   

- Advertisement -