﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Views &amp; BO Updates with Concurrency</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 03:10:35 GMT</lastBuildDate><ttl>20</ttl><item><title>Views &amp; BO Updates with Concurrency</title><link>http://forum.strataframe.net/FindPost12733.aspx</link><description>I have a BO mapped to a view that&amp;nbsp;joins fields from 2 tables in a 1-1 relationship.&amp;nbsp; I've created stored procs to handle the inserts and updates and these work ok except for when it comes to concurrency.&amp;nbsp; My BO always returns "success" when saving when there is a concurrency issue on the main table and I'm not sure how to catch this. &lt;P&gt;Here's how my procedure logic is laid out.&lt;/P&gt;&lt;P&gt;[codesnippet]UPDATE Table1 SET RowVersion = (RowVersion + 1) ... WHERE PK=@Table1PK AND ((RowVersion = @RowVersion) OR (@RowVersion IS NULL))&lt;BR&gt;SELECT @RowVersion = RowVersion FROM Table1 WHERE PK=@Table1PK;&lt;BR&gt;UPDATE Table2 SET ... WHERE Table1FK=@PK[/codesnippet]&lt;/P&gt;&lt;P&gt;When there are no concurrency issues, everything works great.&lt;BR&gt;However, if there is a problem during the&amp;nbsp;table updates I do not receive an error.&lt;/P&gt;&lt;P&gt;I think this&amp;nbsp;is more of a SQL Stored Procedure issue than anything having to deal with the framework but either way I'm not sure how to handle this. Any ideas?&lt;/P&gt;&lt;P&gt;TIA</description><pubDate>Mon, 19 Nov 2007 13:15:55 GMT</pubDate><dc:creator>Crones</dc:creator></item><item><title>RE: Views &amp; BO Updates with Concurrency</title><link>http://forum.strataframe.net/FindPost12791.aspx</link><description>Good to hear.&amp;nbsp; Let me know if you get stuck on anything else with those sprocs.</description><pubDate>Mon, 19 Nov 2007 13:15:55 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Views &amp; BO Updates with Concurrency</title><link>http://forum.strataframe.net/FindPost12785.aspx</link><description>Thanks a bunch for the help.&amp;nbsp; That got me started in the right direction.</description><pubDate>Mon, 19 Nov 2007 11:17:31 GMT</pubDate><dc:creator>Crones</dc:creator></item><item><title>RE: Views &amp; BO Updates with Concurrency</title><link>http://forum.strataframe.net/FindPost12773.aspx</link><description>Ah, the issue is that the BO checks on the number of records modified (the ROWCOUNT in the sproc), so since you're always updating table 2 (not checking on the concurrency in an IF) then the ROWCOUNT will always be greater than 0.&lt;/P&gt;&lt;P&gt;Your best bet is to start a transaction and do something like this:&lt;/P&gt;&lt;P&gt;-- Start a transaction so you can modify both tables without issues&lt;BR&gt;BEGIN TRANSACTION&lt;BR&gt;-- Declare a temp variable to grab the row version from table1&lt;BR&gt;DECLARE @TEMPVERSION&lt;BR&gt;-- Retrieve the row version&lt;BR&gt;SELECT @TEMPVERSION = RowVersion FROM Table1&lt;BR&gt;-- Check the row version to make sure that there isn't a concurrency issue&lt;BR&gt;IF @TEMPVERSION = @RowVersion THEN&lt;BR&gt;-- There isn't a concurrency issue, so update the tables&lt;BR&gt;BEGIN&lt;BR&gt;-- Update Table1&lt;BR&gt;-- Update Table2&lt;BR&gt;-- Retrieve the @RowVersion to return it&lt;BR&gt;-- Committ the transaction because everything worked as expected&lt;BR&gt;COMMITT&lt;BR&gt;END&lt;BR&gt;ELSE&lt;BR&gt;BEGIN&lt;BR&gt;-- Rollback the transaction because there was a concurrency error&lt;BR&gt;-- The ROWCOUNT will automatically return 0 because no rows were &lt;BR&gt;-- updated and it will be detected by the business object as a &lt;BR&gt;-- concurrency error&lt;BR&gt;ROLLBACK&lt;BR&gt;END&lt;/P&gt;&lt;P&gt;I'm not positive on all of the syntax, but it might get you started in the right direction.</description><pubDate>Mon, 19 Nov 2007 10:01:42 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>