Jump to content

Get the id of the fields updated by an update query?


Recommended Posts

Hi guys,

 

I'm fairly sure this isn't going to be possible but hoping I'll be pleasantly surprised!

 

I run an update query when a form is submitted.

I want to be able to extract the fields that have actually been updated by the query...

 

So for example if the update query is running on field_1, field_2 and field_3 but only field_2 is updated, I want to be able to find out that field_2 has been updated but field_1 and field_3 have not.

 

Hope that makes sense!

 

Thanks in advance!

If you're updating using a WHERE clause, then you can just run a SELECT with the same WHERE clause before your update and that will select the rows you're about to change.

 

If you don't know which items are being updated, you can set a trigger on the table to update a "last_edited" timestamp on the table, which will allow you to fake the operation by selecting items that were updated in the last 2 seconds.

 

-Dan

Thanks ManiacDan.

 

But it's not the rows I need to know about...its the actual fields.

 

My query will only return one row - I want to be able to find out which fields in that query have been updated...

Using your 2nd bit of logic I could have a date field related to each field that could be updated and check that way, but it seems a log way around...

 

Any other suggestions?

 

Not even necessary -- you have the ID already!
But I'm assuming he doesn't have the VALUES.  He said he's trying to do something like "the following fields were updated."  Even with the ID, he'll need to select the whole row to figure out the differences.

 

-Dan

I have a form populated with values from the row id.

 

If someone then updates the record using the form, I want to know if there is a nice easy way when running the query which fields have been updated.

 

Yes I can check the original values against the posted values - that is what I have done for the moment, but I want to know if there is an easier way of finding out which fields have been affected by that update query...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.