oracle increment returns inserted record ID02

1, oracle SEQUENCE increment is set; increment rule may be provided in this document; insert a record:

insert into student(student_id,first_name,last_name) values(seq_student.nextval,'','');

seq-student is incremented rule name, seq_student.nextval primary key increment;

2, inserts a row, returns the ID data is inserted; the keyProperty is inserted object properties, i.e. the primary key corresponding to the ID table; order = "after" is inserted after execution, SEQ_A_MODEL_LOSS is the name of the primary key increment rule, SEQ_A_MODEL_LOSS .CURRVAL is inserted to obtain the primary key values, DUAL is the oracle of the virtual table, select the grammatical rules to constitute, oracle to ensure there is always only a dual record.

    <insert id="addLossModel">
        <selectKey resultType="long" order="AFTER" keyProperty="modelId">
            SELECT SEQ_A_MODEL_LOSS.CURRVAL as ID from DUAL
        </selectKey>
        INSERT INTO A_MODEL_LOSS (MODEL_ID,MODEL_CATE_ID,MODEL_CODE,MODEL_STANDARD_NAME,
        MODEL_TRIVIAL_NAME,MODEL_PINYIN_CODE,MODEL_LPCK_CODE,
        MODEL_TYPE,MODEL_CLASS,MODEL_COUNTRY,MODEL_MADE_IN,
        MODEL_IS_INSURER,MODEL_IS_LOSS,MODEL_IS_PIC,MODEL_BIG_PATH,
        MODEL_SMALL_PATH,MODEL_REMARK,MODEL_PART_COUNT,MODEL_VIN_NO,
        MODEL_STRUCT_TYPE,MODEL_GEAR_BOX,MODEL_IS_ENABLE,MODEL_IS_DELETE,
        MODEL_CREATE_DATE,MODEL_UPDATE_DATE,MODEL_OPER_SOURCE,DATA_EDITION,
        VERSION,MODEL_FACTORY,MODEL_DESC,TRAN_EDITION,PART_UPDATE_TIME)
        VALUES
        (SEQ_A_MODEL_LOSS.NEXTVAL,#{modelCateId},#{modelCode},#{modelStandardName},#{modelTrivialName},
        #{modelPinyinCode},#{modelLpckCode},#{modelType},#{modelClass},#{modelCountry},#{modelMadeIn},#{modelIsInsurer}
        ,#{modelIsLoss},#{modelIsPic},#{modelBigPath},#{modelSmallPath},#{modelRemark},#{modelPartCount},#{modelVinNo},
        #{modelStructType},#{modelGearBox},#{modelIsEnable},#{modelIsDelete},#{modelCreateDate},#{modelUpdateDate},
        #{modelOperSource},#{dataEdition},#{version},#{modelFactory},#{modelDesc},#{tranEdition},#{partUpdateTime})
    </insert>

 

Guess you like

Origin www.cnblogs.com/lazyli/p/10973646.html