﻿<?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?)  » Insert as Update history tracking methodology question</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:46:16 GMT</lastBuildDate><ttl>20</ttl><item><title>Insert as Update history tracking methodology question</title><link>http://forum.strataframe.net/FindPost11935.aspx</link><description>We have some tables in our DB that manage history inside the table by only doing Inserts, adding an effective end date.&lt;/P&gt;&lt;P&gt;To do an 'Update' we actually enddate the existing record to Now and then insert a new record with the new data.&amp;nbsp; Were also using stored procs exclusivly for our CRUD.&lt;/P&gt;&lt;P&gt;Our table would look something like this:&lt;/P&gt;&lt;P&gt;-----------------&lt;BR&gt;ProductPrimaryID&lt;BR&gt;ProductID&lt;BR&gt;ProductName&lt;BR&gt;EffectiveEndDate&lt;BR&gt;-----------------&lt;/P&gt;&lt;P&gt;The ProductPrimaryID would be unique for each record in the DB, and the ProductID would persist for each 'Updated' record.&amp;nbsp; So given all this what's the best way to approach this via SF?&amp;nbsp; An update in SF only returns an number for successful rows updated, I need to have it return the new ProductPrimaryID.&amp;nbsp; I thought of calling&amp;nbsp;my Update proc&amp;nbsp;with save() and then&amp;nbsp;refilling my BO with the newly added record.&amp;nbsp; It's an extra trip to the DB but I think it should work.&lt;/P&gt;&lt;P&gt;Anyone else have any ideas or already have a more elegant way to fix this?&lt;/P&gt;&lt;P&gt;Thanks</description><pubDate>Mon, 15 Oct 2007 11:11:34 GMT</pubDate><dc:creator>Rob Toyias</dc:creator></item><item><title>RE: Insert as Update history tracking methodology question</title><link>http://forum.strataframe.net/FindPost11995.aspx</link><description>Thanks Ben,&lt;br&gt;
&lt;br&gt;
That was exactly what I was looking for.&lt;br&gt;
&lt;br&gt;</description><pubDate>Mon, 15 Oct 2007 11:11:34 GMT</pubDate><dc:creator>Rob Toyias</dc:creator></item><item><title>RE: Insert as Update history tracking methodology question</title><link>http://forum.strataframe.net/FindPost11977.aspx</link><description>The first option would be to do what you mentioned about refreshing the record when you send an update.&amp;nbsp; In the OnBeforeSave(), save off the record(s) that need to be refreshed and then on the OnAfterSave() retrieve those records.&amp;nbsp; &lt;/P&gt;&lt;P&gt;The other option would be to create your own DbDataSourceItem class that would be used by just the business object(s) that need this functionality.&amp;nbsp; You would inherit the OracleDataSourceItem class and override the CreateDbCommand() and UpdateRow() methods.&amp;nbsp; On both of them, if the query is anything other than an UPDATE, just pass the command down to the base class, otherwise, handle it as needed.&amp;nbsp; You can use the DataRowState.Modified portion of the UpdateRow() method as a template.</description><pubDate>Mon, 15 Oct 2007 09:29:50 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Insert as Update history tracking methodology question</title><link>http://forum.strataframe.net/FindPost11959.aspx</link><description>We are already using sprocs for all the CRUD.&amp;nbsp; my real issue is that the signature for the Update sproc in SF only returns a rowcount, not a keyID.&amp;nbsp; This makes sense since why would SF expect the keyid to change in an Update.&lt;/P&gt;&lt;P&gt;So&amp;nbsp;if call my Update sproc I'll then have a situation where my BO will have the correct data with an incorrect keyID.&amp;nbsp; Like this:&lt;/P&gt;&lt;P&gt;Table:&lt;BR&gt;KeyID, ProductID, Name, Color, current&lt;BR&gt;&lt;BR&gt;record 1&lt;BR&gt;1, 1001, SomeThing, Blue, true&lt;/P&gt;&lt;P&gt;Fill my ProductBO as follows:&lt;BR&gt;MyProduct.FillByPrimaryKey(1);&lt;/P&gt;&lt;P&gt;Now I change the MyProduct BO to this (the sproc manages the "current" part):&lt;BR&gt;1, 1001, SomeThing2, Blue2&lt;BR&gt;&lt;BR&gt;I call my Update sproc with MyProduct.Save();&amp;nbsp; &lt;BR&gt;&lt;BR&gt;Now the DB looks like:&lt;BR&gt;1, 1001, SomeThing, Blue, false&lt;BR&gt;2, 1001, SomeThing2, Blue2, true&lt;BR&gt;&lt;BR&gt;This updates the data in the DB as I needed but leaves my BO with a bad KeyID (1 when it needs to be 2).&amp;nbsp; I havent implemented it yet but I am planning on&amp;nbsp;refreshing the BO after an Update to get the new real record.&amp;nbsp; This seems inelegant and to easy to screw up&amp;nbsp;so I was hoping someone else had a better strategy.&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR&gt;</description><pubDate>Fri, 12 Oct 2007 14:23:31 GMT</pubDate><dc:creator>Rob Toyias</dc:creator></item><item><title>RE: Insert as Update history tracking methodology question</title><link>http://forum.strataframe.net/FindPost11952.aspx</link><description>I think using sprocs for CRUD would be the way to go.  The sproc can handle the logic to add the row during update, there would be no extra trips to the db (btw, SF does an extra one to update the data during updates anyway...I think).  There is a topic in help to show you the signature of the sproc.</description><pubDate>Fri, 12 Oct 2007 03:17:37 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>