sql報錯、ORA-01427: 單行子查詢返回多個行sql
select * from ( select row_.*, rownum rownum_ from ( select ids "ids" , procinstid "procinstid" , businesskey "businesskey" , sysordertitle "sysordertitle" , sysordercreator "sysordercreator" , startuserid "startuserid" , procdefid "procdefid" , to_char(starttime) "starttime" , to_char(endtime) "endtime" , key "key" , name "name", currentinfo "currentinfo" from ( select proc.id_ ids, proc.proc_inst_id_ procinstid, proc.business_key_ businesskey, (select v.TEXT_ from ACT_HI_VARINST v where v.proc_inst_id_ = proc.proc_inst_id_ and v.NAME_ = 'sysOrderTitle') sysOrderTitle, (select v.TEXT_ from ACT_HI_VARINST v where v.proc_inst_id_ = proc.proc_inst_id_ and v.NAME_ = 'sysOrderCreator') sysOrderCreator, proc.start_user_id_ startuserid, proc.proc_def_id_ procdefid, to_char(proc.start_time_,'yyyy-MM-dd hh24:mi:ss') starttime , to_char(proc.end_time_,'yyyy-MM-dd hh24:mi:ss') endtime , def.key_ key , def.name_ name, (select to_char(wmsys.wm_concat(to_char(act_name_ || ':' || act.assignee_))) from act_hi_actinst act where act.proc_inst_id_ = proc.proc_inst_id_ and act.end_time_ is null and act.act_type_ in ('startEvent', 'userTask')) currentinfo from act_hi_procinst proc, act_re_procdef def where proc.proc_def_id_ = def.id_ ) temp where 1=1 and temp.startuserid = 'wanghongfa' order by starttime desc ) row_ ) where rownum_ > 0 and rownum_ <= 4
分析子查詢發現問題,單行子查詢返回多個行spa
select (select v.TEXT_ from ACT_HI_VARINST v where v.proc_inst_id_ = proc.proc_inst_id_ and v.NAME_ = 'sysOrderTitle') sysOrderTitle from act_hi_procinst proc, act_re_procdef def where proc.proc_def_id_ = def.id_ ;code
其中:select v.TEXT_ from ACT_HI_VARINST v where v.proc_inst_id_ = proc.proc_inst_id_ and v.NAME_ = 'sysOrderTitle',應該返回與act_hi_procinst proc, act_re_procdef def where proc.proc_def_id_ = def.id_ 同樣的行數的記錄,可是從圖中咱們能夠看出PROC_INST_ID_重複出現,實例變量表多了一條記錄。blog
我怎麼會保存多了記錄在ACT_HI_VARINST 表裏面呢,緣由是在從新申請環節,保存了一些關鍵字。ci
解決辦法:從新申請不要保存有關鍵字
sysOrderTitle(是子查詢條件,任務環節不要保存這個字段,否則報錯--單行子查詢返回多個行)
sysOrderCreator(是子查詢條件,後臺也要作處理,不要讓其保存在任務環節)
sysOrderKey(不是子查詢條件,但任務環節沒有必要保存)
sysOrderDesc(不是子查詢條件,任務環節也會有該字段)it