为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:dm8
【操作系统】:window10
【CPU】:
【问题描述】:由于公司需求,将mysql转成达梦数据库,在进行列表查询的时候,原sql报错“语法分析出错”SELECT * FROM ( SELECT TMP., ROWNUM ROW_ID FROM ( SELECT person.person_id, person.person_type, personType.dict_label AS person_type_name, person.staff_type, staffType.dict_label AS staff_type_name, person.card_type, dict.dict_label AS card_type_name, person.card_id, person.real_name, person.phone, person.sex, person.person_photo, person.birth, person.email, person.native_place, person.nation, person.marital_status, person.politics_status, person.health_status, person.id_type, person.id_number, person.dept_id, person.post_id, person.duty, person.hire_date, person.job_number, person.job_status, person.office_phone, person.professional_title, person.professional_title_number, person.seniority, person.year_plus_experience, person.experience, person.highest_education, person.highest_degree, person.profession, person.school, person.diploma_number, person.ceng_number, person.accessory, person.contractor_id, person.dimission_date, person.create_by, person.create_time, person.update_by, person.update_time, person.remark, person.gate_through, dept.dept_name, post.post_name, card.ic_card_id, card.card_power, IFNULL(onlineCard.online,0) AS online, gate.status_id AS gate_status, u.user_id, u.user_name FROM core_person person LEFT JOIN system_dept dept ON person.dept_id = dept.dept_id LEFT JOIN system_post post ON person.post_id = post.post_id LEFT JOIN device_card card ON person.card_id=card.card_id LEFT JOIN system_dict personType ON person.person_type = personType.dict_value AND personType.dict_type = 'person_type' LEFT JOIN system_dict staffType ON person.staff_type = staffType.dict_value AND staffType.dict_type = 'staff_type' LEFT JOIN system_dict dict ON card.card_type = dict.dict_value AND dict.dict_type = 'card_type' LEFT JOIN (SELECT p.card_id,if(c.card_id IS NULL, 0, 1) AS online FROM core_person p LEFT JOIN position_current c ON c.card_id=p.card_id AND c.accept_time>DATE_SUB(now(),INTERVAL (SELECT IFNULL(config_value,10)*60 FROM system_config WHERE config_key='online_minute') SECOND) and c.card_id IS NOT NULL WHERE p.card_id IS NOT NULL) onlineCard ON person.card_id=onlineCard.card_id LEFT JOIN (select status_id,card_id from (select status_id,card_id from record_gate ORDER BY accept_time desc LIMIT 1000000) g GROUP BY card_id) gate ON person.card_id=gate.card_id LEFT JOIN system_user u ON person.person_id=u.person_id WHERE person.person_type =? ) TMP WHERE ROWNUM <=?) WHERE ROW_ID > ?
<sql id="selectVo">
SELECT
person.person_id,
person.person_type,
personType.dict_label AS person_type_name,
person.staff_type,
staffType.dict_label AS staff_type_name,
person.card_type,
dict.dict_label AS card_type_name,
person.card_id,
person.real_name,
person.phone,
person.sex,
person.person_photo,
person.birth,
person.email,
person.native_place,
person.nation,
person.marital_status,
person.politics_status,
person.health_status,
person.id_type,
person.id_number,
person.dept_id,
person.post_id,
person.duty,
person.hire_date,
person.job_number,
person.job_status,
person.office_phone,
person.professional_title,
person.professional_title_number,
person.seniority,
person.year_plus_experience,
person.experience,
person.highest_education,
person.highest_degree,
person.profession,
person.school,
person.diploma_number,
person.ceng_number,
person.accessory,
person.contractor_id,
person.dimission_date,
person.create_by,
person.create_time,
person.update_by,
person.update_time,
person.remark,
person.gate_through,
dept.dept_name,
post.post_name,
card.ic_card_id,
card.card_power,
IFNULL(onlineCard.online,0) AS online,
gate.status_id AS gate_status,
u.user_id,
u.user_name
FROM
core_person person
LEFT JOIN system_dept dept ON person.dept_id = dept.dept_id
LEFT JOIN system_post post ON person.post_id = post.post_id
LEFT JOIN device_card card ON person.card_id=card.card_id
LEFT JOIN system_dict personType ON person.person_type = personType.dict_value AND personType.dict_type = 'person_type'
LEFT JOIN system_dict staffType ON person.staff_type = staffType.dict_value AND staffType.dict_type = 'staff_type'
LEFT JOIN system_dict dict ON card.card_type = dict.dict_value AND dict.dict_type = 'card_type'
LEFT JOIN (SELECT p.card_id,if(c.card_id IS NULL, 0, 1) AS online FROM core_person p LEFT JOIN position_current c ON c.card_id=p.card_id AND c.accept_time>dateadd(SECOND,-(SELECT IFNULL(config_value,10)*60 FROM system_config WHERE config_key='online_minute'),now()) and c.card_id IS NOT NULL WHERE p.card_id IS NOT NULL) onlineCard ON person.card_id=onlineCard.card_id
LEFT JOIN (select status_id,card_id from (select status_id,card_id from record_gate ORDER BY accept_time desc LIMIT 1000000) g GROUP BY card_id) gate ON person.card_id=gate.card_id
LEFT JOIN system_user u ON person.person_id=u.person_id
</sql>
原sql放在这里了,有大佬能帮帮忙解惑吗
SQL开始部分
SELECT *
FROM (SELECT TMP., ROWNUM ROW_ID
FROM (......
其中的 TMP. 后没有字段名,你看看是不是没有正确拼接上字段列表
<select id="listPage" parameterType="PersonPageBody" resultMap="basicResult">
<include refid="selectVo"/>
<where>
<if test="cardId != null and cardId != 0">
AND person.card_id like concat('%', #{cardId}, '%')
</if>
<if test="realName != null and realName != ''">
AND person.real_name like concat('%', #{realName}, '%') escape '/'
</if>
<if test="personType != null and personType != ''">
AND person.person_type =#{personType}
</if>
<if test="staffType != null and staffType != ''">
AND person.staff_type =#{staffType}
</if>
<if test="contractorId != null">
AND person.contractor_id =#{contractorId}
</if>
<if test="deptId != null">
AND person.dept_id =#{deptId}
</if>
<if test="jobStatus != null and jobStatus != ''">
AND person.job_status =#{jobStatus}
</if>
<if test="jobNumber != null and jobNumber != ''">
AND person.job_number =#{jobNumber}
</if>
<if test="personIds != null and personIds.size()>0">
AND person.person_id in
<foreach collection="personIds" item="personId" open="(" separator="," close=")">
#{personId}
</foreach>
</if>
<if test="deptIds != null and deptIds.size()>0">
AND person.dept_id in
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</if>
<if test="icCardId != null ">
AND card.ic_card_id like concat('%', #{icCardId}, '%') escape '/'
</if>
<if test="cardPower != null">
AND card.card_power <= #{cardPower}
</if>
<if test="online != null">
AND onlineCard.online= #{online}
</if>
<if test="unregistered != null">
AND person.person_id NOT IN (SELECT person_id FROM system_user WHERE person_id IS NOT NULL)
</if>
<if test="gateStatus != null and gateStatus != ''">
AND gate.status_id =#{gateStatus}
</if>
<if test="beginTime != null">
and person.update_time >= #{beginTime}
</if>
<if test="endTime != null">
and person.update_time <= #{endTime}
</if>
<if test="postName != null and postName != ''">
AND post.post_name like concat('%', #{postName}, '%') escape '/'
</if>
</where>
</select>