mercredi 14 janvier 2015

Throwing a message to the user in SQL Server

I need to have a nested if statement in an update trigger. How do I say with an If statement in sql -- if two columns don't equal each other - throw an error message (don't shut down the system - just throw a message alerting the user).



If(@order_tot_paid_amt > 0) -- that means that the user has entered a value. (and its calculated)


I've reviewed a few of the existing posts, and they differ from what I am asking. Do I need a catch statement? (I know in c++ you need a catch statement otherwise things shut down).


What I have so far is (and I know I'm missing data).



IF (@order_tot_paid_amt > 0)
IF @order_tot_paid_amt <> (select pmt_rcvd_amt from LT_CHC_TOURS_RSV_CS where id_key = @id_key)
THROW ...
CATCH ...


I don't know where to get all the commands for throw and catch.


Aucun commentaire:

Enregistrer un commentaire