oracle varchar转化为char,case when里面经常出现

select * from
 (
 select ta.*,(case when (ta.task_type='1' or ta.task_type='2') then (select to_char(b.name) from act_basicinfo b where 1=1 and b.events_uid=ta.rel_uid ) else (select (case when y.HANDLE_APPLYTYPE=0 then '固定资产借用' when y.HANDLE_APPLYTYPE=1 then '固定资产领用' when y.HANDLE_APPLYTYPE=2 then '固定资产维修' when y.HANDLE_APPLYTYPE=3 then '固定资产报废' else '' end) applyName from YLOA_ASSETHANDLEAPPLY y where y.HANDLE_UID=ta.rel_uid) end) activity_name from
(
select t.wftask_uid,t.wfinst_uid,t.task_seq,t.task_name,t.receivedate,t.task_type,(case when t.task_type='1' then '活动审批' when t.task_type='2' then '预算审批' when t.task_type='3' then '固定资产审批' else '' end) type_name,(case when t.task_type='2' then (select b.events_uid from act_resourcesgroup b  where b.resgroup_uid=i.rel_uid) else i.rel_uid end)REL_UID from wf_task t left join wf_instance i on(t.wfinst_uid=i.wfinst_uid) where TASK_STATUS=0 {? AND APPROVER_UID=#APPROVER_UID#}  {? AND t.task_name LIKE CONCAT(CONCAT('%',#name#),'%') ESCAPE '/' }
) ta
) m  where 1=1 {? AND m.activity_name LIKE CONCAT(CONCAT('%',#activity_name#),'%') ESCAPE '/' } order by m.receivedate desc

因为name为nvarchar,而'固定资长报废'为char,所以在case when时需要转化

猜你喜欢

转载自wshyj18.iteye.com/blog/1725596
今日推荐