postgresql insert and update 插入更新

 
     
    UPDATE estate.web_msg_center SET json_data = #{jsonData,jdbcType=OTHER}:: jsonb, area_id = #{areaId,jdbcType=SMALLINT}, alertmsg = #{alertmsg,jdbcType=VARCHAR}  WHERE dep_id=#{depId,jdbcType=INTEGER} and msg_type=#{msgType,jdbcType=SMALLINT};
    INSERT INTO estate.web_msg_center (
        msg_type,
        create_time,
        status,
        dep_id,
        json_data,
        area_id,
        alertmsg
    )
     SELECT #{msgType,jdbcType=SMALLINT}, #{createTime,jdbcType=TIMESTAMP},#{status,jdbcType=SMALLINT},#{depId,jdbcType=INTEGER},#{jsonData}::jsonb,#{areaId,jdbcType=SMALLINT},#{alertmsg,jdbcType=VARCHAR}
     WHERE NOT EXISTS (SELECT 1 FROM estate.web_msg_center  WHERE dep_id=#{depId,jdbcType=INTEGER} and msg_type=#{msgType,jdbcType=SMALLINT});
     
 

你可能感兴趣的:(数据库开发)