<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="stuTest.mapper.StudentMapper">
    <select id="selectStudent" resultType="stuTest.pojo.Student">
        select N_STUDENT_ID as id ,
               VC_STUDENT_CODE as code,
               VC_STUDENT_NAME as name,
               N_SEX as sex,
               N_GRADE as grade,
               N_MAJOR as major,
               VC_DETAIL as detaile
        from t_student
        where upper(VC_STUDENT_NAME) like concat("%",upper(#{name}),"%");
    </select>

    <insert id="insertStudent" keyProperty="id" useGeneratedKeys="true">
        insert into t_student (VC_STUDENT_CODE,VC_STUDENT_NAME,N_SEX,N_GRADE,N_MAJOR,VC_DETAIL)
        values (#{code},#{name},#{sex},#{grade},#{major},#{detail});
    </insert>

    <delete id="deleteStudent">
        delete from t_student
        where N_STUDENT_ID=#{id};
    </delete>

    <update id="updateStudent">
        update t_student set VC_STUDENT_CODE=#{code},
                             VC_STUDENT_NAME=#{name},
                             N_SEX=#{sex},
                             N_GRADE=#{grade},
                             N_MAJOR=#{major},
                             VC_DETAIL=#{detail}
        where N_STUDENT_ID=#{id};
    </update>
</mapper>