Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to determine if SQL Update successful?
Message
From
24/11/2021 12:02:05
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01682800
Message ID:
01682820
Views:
53
>>>How do I determine, in my PRG code, that a record has been updated? That is, without searching for the Field2 = 'XYZ'.
>>>
>>
>> Are you looking for absolute verification that indeed, the row was changed, and specifically, that the column was changed from 'ABC' to 'XYZ'?
>
>Yes.

As Naomi said, you can use the OUTPUT clause....OUTPUT actually gives you visibility into the DELETED and INSERTED tables that are otherwise private to a trigger. They allow you to see the "before" and "after" values for the table you're updating.

Microsoft basically created the OUTPUT to give people the "low hanging fruit" of some of the benefits of a trigger, without needing to write a full trigger. That's not to disparage it - it's a nice feature.

My 2 cents, if you need an audit trail of who changed what and when....you might want to look at either update triggers or change data capture. Triggers are great, though you do have to write a bit of code (which shouldn't scare someone). Change Data Capture "usually" requires less code - though there are some nuances to be aware of.....it's good but not perfect.

After years, my 2 cents is that triggers are the best way to go, to build a custom log of who changed what and when.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform