How we can use mysql_affected_rows() in stored procedure

后端 未结 3 1811
清酒与你
清酒与你 2021-02-07 04:13

How we can use mysql_affected_rows() in stored procedure..

3条回答
  •  深忆病人
    2021-02-07 04:47

    example

    BEGIN
    DECLARE countRow INT;
    DECLARE roomTypeId INT;
            INSERT INTO room_type (room_type)
    SELECT * FROM (SELECT paramRoomType) AS tmp
    WHERE NOT EXISTS (
        SELECT room_type_id FROM room_type WHERE room_type = paramRoomType 
    ) LIMIT 1;
    SET countRow =  ROW_COUNT();
    
    IF(countRow >  0) THEN
        SET roomTypeId =  LAST_INSERT_ID();
        INSERT hotel_has_room_type (hotel_id,room_type_id) VALUES (paramHotelId,roomTypeId);
    END IF;
    END
    

提交回复
热议问题