CREATE procedure usp_set_night_free(IN booking_id_param bigint)
BEGIN
DECLARE
@price_per_night INT;
SELECT b.price
INTO @price_per_night
FROM booked_rooms as b
WHERE b.booking_id = booking_id_param
LIMIT 1;
UPDATE bookings as b
JOIN booked_rooms b2 on b2.id = b.id
SET b.total_price = b.total_price - @price_per_night
WHERE b.id = b2.booking_id;
END;
But get - ResultSet is from UPDATE. No Data. - and I don't know where the problem could be. Help is appreciated.
This is a Microsoft SQL Server forum. But still, this below section is concerning. You join to booked_rooms on id and then a WHERE clause on booking_id?
JOIN booked_rooms b2 on b2.id = b.id
WHERE b.id = b2.booking_id;
Thank you. I posted this at around 1h after midnight after spending whole day on this procedure so I was obviously not looking where I post. Your remark is correct, it should be
But I still get that error I will try debugging as @harishgg1 has suggested below.