Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Database user profileDatabase user profile
Previous
 
Next
New Post
11/26/2008 12:24 PM
 

Hi All

My DNN (4.8) intranet user profile has a number of custom fields that affect other systems eg: email settings (auto answer message etc) also bank details, next of kin and suchlike. 

When the user updates their profile I need to record that fact and update other systems with the values from the user profile.

I have created a table called DirtyData and put a trigger on the userProfile table which puts a record in dirtydata whenever a users profile is updated.  Then there is another process which examines dirtydata and syncronises profile settings with the other systems.

However, when the profile is updated it appears that multiple updates actually take place and my dirtydata table is collecting 15 or so new records !!

Does anyone know ........

Is the profile table updated more than once when a user updates their profile ?

If not can anyone think what could be causing my trigger to fire multiple times.

Many thanks - Guy

 
New Post
11/27/2008 2:20 AM
 

I'm not sure about the multiple updates, but considering your "synch" process you might consider tightening things up a bit by adding a log table of hashed "profile" values to compare against before your "other" process does its synch step.  This would let you determine when it's appropriate to commit a new data entry to the DirtyData table.

Er...what the heck is he talking about?
Ok, this is what I'm talking about:  When your trigger fires, concatenate all the profile values into one big string and then create a hash value of that string.  Check this hash value against the most recent hash value (if any) associated with the approrpiate userid from your special "hash log" table (a table with previous hashed values and their associated userids).  If the hash matches, don't add anything to the "DirtyData" table (because you've got a duplicate UPDATE).  If it does not match, add the profile data to the DirtyData table and add the userid and hash value to your hash log table.

This will help alleviate your current issue though it won't solve the mystery of the multiple UPDATES.  Beyond that, though, it should prevent you from ever performing unnecessary synchs when a user clicks "UPDATE" without having changed any profile data or when some event causes your table trigger to fire when it does not need to (when no profile info has changed).  It will also inherently provide an audit history showing what profiles are actually changed as opposed to using the general SQL log to show only how many times updates are performed (updated but possibly with identical info and therefore not actually changed). Note that you'd probably want to add a timestamp column if you're interested in audit trails.


Why Bother with a Hash Value?
Unless you want a complete audit trail of what profile data was changed with each UPDATE, there are several decent reasons why a hash value (instead of the actual data) could be considered desirable:

  1. You don't have to worry (too much) about protecting the data in the hash table.  This is nice when you're dealing with personal data and have to keep track of where copies of the info get stored.
  2. Your hash values won't require a lot of storage space compared to storing copies of all profile field values.
  3. Your hash log table schema doesn't have to change if the user profile table schema changes (i.e., if more profile columns are added).
  4. It sounds pretty cool when you're explaining the process to your non-technical boss just before annual review time.


OR....
Or you could just have your trigger compare the incoming profile data to the existing profile data and then not perform the update if the incoming matches the existing.  Easy but not nearly as exciting as hash log tables.


Hopefully someone can answer your REAL question regarding the multiple UPDATEs.  All the stuff about hashed values was really just for fun-
-mamlin


esmamlin atxgeek.me
 
New Post
11/27/2008 5:46 AM
 

Hey Mamlin - Many thanks for your very helpful post. It's certainly got me thinking about some additional sanity measures I should include.

Who knows, I may even stumble across the multiple record issue while I'm doing that :o)

Guy

 
New Post
11/27/2008 10:22 AM
 

Hi All

The problem is resolved using a combination of the new trigger function (newly added in sql 2005) update(), which tells me if the fields I'm interested in have been updated and also comparing the old and new values from the deleted table and the inserted table.  Pseudocode follows ....

-- Was propertyvalue updated ?

IF (UPDATE(PropertyValue))

BEGIN

-- Is data being changed?

-- Get new & old property values
SELECT @PropValueNew = ( SELECT i.PropertyValue FROM INSERTED i )
SELECT @PropValueOld = ( SELECT d.PropertyValue FROM DELETED d )

if (@PropValueNew <> @PropValueOld)

BEGIN -- Data has been changed

 

Insert into dbo.DirtyData etc etc ......

END

The above may not be perfect but it's fixed the problem and the updates are now being properly processed.

Cheers - Guy

 

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Database user profileDatabase user profile


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out