假设现在有一个招聘会公司表,一个招聘岗位表。。其中招聘岗位的co_id关联招聘公司的id。一个招聘会公司可能会发布很多个招聘岗位。name在添加招聘岗位的时候
<insert id="addFairPosition" parameterType="java.util.List">
INSERT INTO T_JOB_FAIR_POSITION (id, co_id, name, hire_num, salary, address, summary, require)
SELECT T_JOB_FAIR_POSITION_ID_SEQ.nextval id, A.* FROM (
<foreach collection="list" index="index" item="item" separator="UNION ALL">
SELECT #{item.coId} co_id, #{item.name} name, #{item.hireNum} hire_num, #{item.salary} salary,
#{item.address} address, #{item.summary} summary, #{item.require} require FROM dual
</foreach>
)A
</insert>
其中T_JOB_FAIR_POSITION_ID_SEQ.nextval 是获得招聘岗位id的下一个值,dual为Oracle中虚拟表,是不存在的。。foreach是在循环添加招聘岗位。
<!--添加招聘会公司与职位信息-->
//T_JOB_FAIR_CO_ID_SEQ.nextval获得T_JOB_FAIR表中co_id 的下一个值,dual为虚拟表,是不存在的
<select id="getFairCoSEQ" resultType="java.lang.String">
SELECT T_JOB_FAIR_CO_ID_SEQ.nextval FROM dual
</select>
//增加招聘会的sql语句
<insert id="addFairCo" parameterType="com.tecsun.sisp.iface.server.vo.FairCoBean">
INSERT INTO T_JOB_FAIR_CO (id, fair_id, name, contact, tel, mobile, address, summary)
VALUES (#{id}, #{fairId}, #{name}, #{contact}, #{tel}, #{mobile}, #{address}, #{summary})
</insert>
<insert id="uploadCoAccount" parameterType="com.tecsun.sisp.iface.server.vo.CoBean">
INSERT INTO T_CO_USER(ID, LOG_NAME, PASSWORD, NAME, CONTACT,
TEL, MOBILE, EMAIL, ADDRESS, FAX,
SUMMARY, STATUS, CREATE_TIME, CHECK_TIME, CHECK_MSG, INDUSTRY_CATEGORY)
SELECT T_CO_USER_ID_SEQ.nextval id, A.* FROM (
<foreach collection="list" index="index" item="item" separator="UNION ALL">
SELECT #{item.logName} LOG_NAME, #{item.password} PASSWORD, #{item.name} NAME, #{item.contact} CONTACT,
#{item.tel} TEL, #{item.mobile} MOBILE, #{item.email} EMAIL, #{item.address} ADDRESS, #{item.fax} FAX,
#{item.summary} SUMMARY, #{item.status} STATUS, #{item.createTime} CREATE_TIME,
#{item.checkTime} CHECK_TIME, #{item.checkMsg} CHECK_MSG, #{item.industryCategory} INDUSTRY_CATEGORY
FROM dual
</foreach>
)A
</insert>