SQLTeam.com | Weblogs | Forums

ResultSet is from UPDATE. No Data

I have a procedure

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.

Welcome.

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;
1 Like

hi

you will have to debug .. i mean each step what's happening .. you will have to check

some thing like below

1 Like

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 :tired_face: I will try debugging as @harishgg1 has suggested below.

What sql server stack is it? Mysql? And you still have not provided explanation for

JOIN booked_rooms b2 on b2.id = b.id
WHERE b.id = b2.booking_id;