Araw
Araw

Reputation: 2478

Check if a query in stored procedure was successful or not

Is it possible to see if a query within a stored procedure was successful or not? For example, I want to know if the following query was successful:

if (UPDATE CurrentState SET buyer = bid
                    WHERE ID = company_id_var
                    AND buyer < bid;)
then
    //Variable was updated, do something
else
    //Variable was not updated, do something else
end if

I`m trying to avoid to use a SELECT-query to check if it has been set to the the new value.

Thanks for any help!

Upvotes: 1

Views: 3425

Answers (2)

Matt H
Matt H

Reputation: 638

You can do something with an on-update trigger.

Upvotes: 0

Vikdor
Vikdor

Reputation: 24134

You can use the ROW_COUNT function to see if anything got updated.

Upvotes: 2

Related Questions