I want to create stored procedure which will block to update document (UDO) which has value of 'Closed' in field (ComboBox) of U_status. I tried to do that but as it seems it is checking value ('Closed') of the form not value of database table. It is blocking before update value to 'Closed' in the table.
Below is what I tried to do
if @object_type='PWQ' AND @transaction_type in ('U')<br>BEGIN<br>SELECT @error=999, @error_message='Document is closed, you cannot change anything' FROM [@PWQ] WHERE [@PWQ].DocEntry=@list_of_cols_val_tab_del<br>AND( exists (SELECT top 1 T.U_status FROM [@PWQ] as T WHERE T.DocEntry=[@PWQ].DocEntry AND ISNULL(T.U_status,'')='Closed')<br>AND<br>ISNULL([@PWQ].Canceled,'')='N'<br>) <br>SELECT @error, @error_message<br>END
Please anyone can help me