CREATE OR REPLACE PACKAGE BODY mypack IS
PROCEDURE myproc(
        in_real_name IN VARCHAR2,
        in_companyId IN VARCHAR2,
        in_party IN VARCHAR2,
        in_startDate IN VARCHAR2,
        in_endDate IN VARCHAR2,
        outcursor IN OUT mycursor
    )
IS
        startDatetmp VARCHAR2(100) := in_startDate || ' 00:00:00';
        endDatetmp VARCHAR2(100) := in_endDate || ' 23:59:59';
        condition VARCHAR2(500) := 'b.area_id = 201';
 
BEGIN
        if in_real_name is not null then
        condition := condition||' and b.real_name like'||'%'||in_real_name||'%';
        end if;
        if in_companyId is not null then
        condition := condition||' and  b.company_id ='||in_companyId;
        end if;
        if in_party is not null then
        condition := condition||' and b.party like'||'%'||in_party||'%';
        end if;
        condition := condition||' and company_id is not null';
         
OPEN outcursor FOR
      select t.userId,
        t.companyId,
        t.realname,
        t.companyName,
        t.party,
        t.dlcs,
        mkcs,
        time,
        dz1 + dz2 + dz3 dz,
        dt,
        spcs,
        xwcs,
        wxd,
        mkcs + dt + wxd * 10 + (dz1 + dz2 + dz3) * 0.1 + t.time + t.spcs +
        t.xwcs yhjf
   from (select b.id as userId,
                b.company_id as companyId,
                b.real_name as realname,
                (select count(id)
                   from t_record
                  where name = '登陆次数'
                    and user_id = b.id
                    and create_date >=
                        to_date(startDatetmp,
                                'yyyy-mm-dd hh24:mi:ss')
                    and create_date <=
                        to_date(endDatetmp,
                                'yyyy-mm-dd hh24:mi:ss')) dlcs,
                (select count(id)
                   from t_record
                  where name != '登陆次数'
                    and user_id = b.id
                    and create_date >=
                        to_date(startDatetmp,
                                'yyyy-mm-dd hh24:mi:ss')
                    and create_date <=
                        to_date(endDatetmp,
                                'yyyy-mm-dd hh24:mi:ss')) mkcs,
                nvl((select sum(use_time)
                      from T_VIDEO_RECORD
                     where user_id = b.id
                       and start_date >=
                           to_date(startDatetmp,
                                   'yyyy-mm-dd hh24:mi:ss')
                       and start_date <=
                           to_date(endDatetmp,
                                   'yyyy-mm-dd hh24:mi:ss')),
                    0) time,
                (select company_name from t_company where id = company_id) companyName,
                b.party,
                (select count(id)
                   from t_praise
                  where userid = b.id
                    and createtime >=
                        to_date(startDatetmp,
                                'yyyy-mm-dd hh24:mi:ss')
                    and createtime <=
                        to_date(endDatetmp,
                                'yyyy-mm-dd hh24:mi:ss')) dz1,
                (select count(id)
                   from t_picture_praise
                  where user_id = b.id
                    and create_date >=
                        to_date(startDatetmp,
                                'yyyy-mm-dd hh24:mi:ss')
                    and create_date <=
                        to_date(endDatetmp,
                                'yyyy-mm-dd hh24:mi:ss')) dz2,
                (select count(video_id)
                   from t_video_praise
                  where user_id = b.id
                    and create_date >=
                        to_date(startDatetmp,
                                'yyyy-mm-dd hh24:mi:ss')
                    and create_date <=
                        to_date(endDatetmp,
                                'yyyy-mm-dd hh24:mi:ss')) dz3,
                (select count(id)
                   from t_dyn_details
                  where user_id = b.id
                    and dyn_id = 67
                    and create_date >=
                        to_date(startDatetmp,
                                'yyyy-mm-dd hh24:mi:ss')
                    and create_date <=
                        to_date(endDatetmp,
                                'yyyy-mm-dd hh24:mi:ss')) wxd,
                nvl((select sum(score)
                      from t_question_record
                     where user_id = b.id
                       and create_date >=
                           to_date(startDatetmp,
                                   'yyyy-mm-dd hh24:mi:ss')
                       and create_date <=
                           to_date(endDatetmp,
                                   'yyyy-mm-dd hh24:mi:ss')),
                    0) dt,
                get_user_spcs(b.id, in_startDate, in_endDate) spcs,
                get_user_xwcs(b.id, in_startDate, in_endDate) xwcs
           from t_user b
          where condition) t;RETURN;
END myproc;
END;
这个condition的代入好像一直有问题,请大神帮看下如何把它带到游标查询的sql中,感谢