<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Trigger on Add table in versioned SDE in Geodatabase Questions</title>
    <link>https://community.esri.com/t5/geodatabase-questions/trigger-on-add-table-in-versioned-sde/m-p/864054#M5916</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was looking for a way to capture data edits on versioned database to update a non-gis system. (DB Oracle 11G)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; text-decoration: underline;"&gt;&lt;STRONG&gt;What I have done so far?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have created after insert or update trigger on the Add table of the featureclass,&lt;/P&gt;&lt;P&gt;it checks if the edit is posted,&lt;/P&gt;&lt;P&gt;if posted - then the updates are inserted into a temp table (from where its transferred to the other system)&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;create or replace TRIGGER "ADMIN"."TEST_TRG" AFTER INSERT OR UPDATE OF STATE
ON A3401
FOR EACH ROW 
DECLARE
isPost NUMBER;
BEGIN
SELECT COUNT(*) INTO isPost FROM SDE.STATES WHERE SDE.STATES.STATE_ID=:new.SDE_STATE_ID AND SDE.STATES.LINEAGE_NAME=SDE.STATES.STATE_ID;
IF INSERTING AND (isPost &amp;gt; 0) AND (:new.STATE=0 OR :new.STATE is NULL) THEN
INSERT INTO TEST_TRIGGER (OBJECTID,LOCATION,ID,STATE,TYPE) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUES ( :new.OBJECTID,:new.LOCATION,:new.ID,'NEW','UPDATED');
ELSE IF UPDATING('STATE') AND (:new.STATE=0) AND (:old.STATE=1) AND (isPost &amp;gt; 0) )&amp;nbsp; THEN&amp;nbsp; 
INSERT INTO TEST_TRIGGER (OBJECTID,LOCATION,ID,STATE,TYPE)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUES ( :new.OBJECTID,:new.LOCATION,:new.ID,'NEW','CREATED');
ELSE 
null;
END IF;
END IF;
END;&lt;/PRE&gt;&lt;P&gt;The problem I have here is, I want to capture the update only if they are done on specific columns. When the edits are posted, its always an insert and I won't be able to figure out what its previous value was. I tried writing a before insert trigger and compare with the value from Multi-versioned view but that runs into mutating table problem. [Note: The above script is not optimized, I am just trying to check the possibility of capturing the edit]&lt;/P&gt;&lt;P&gt;Possibly I am doing something wrong here or there is a better way to achieve this. Request help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 10:43:52 GMT</pubDate>
    <dc:creator>PramodHarithsa1</dc:creator>
    <dc:date>2021-12-12T10:43:52Z</dc:date>
    <item>
      <title>Trigger on Add table in versioned SDE</title>
      <link>https://community.esri.com/t5/geodatabase-questions/trigger-on-add-table-in-versioned-sde/m-p/864054#M5916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was looking for a way to capture data edits on versioned database to update a non-gis system. (DB Oracle 11G)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; text-decoration: underline;"&gt;&lt;STRONG&gt;What I have done so far?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have created after insert or update trigger on the Add table of the featureclass,&lt;/P&gt;&lt;P&gt;it checks if the edit is posted,&lt;/P&gt;&lt;P&gt;if posted - then the updates are inserted into a temp table (from where its transferred to the other system)&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;create or replace TRIGGER "ADMIN"."TEST_TRG" AFTER INSERT OR UPDATE OF STATE
ON A3401
FOR EACH ROW 
DECLARE
isPost NUMBER;
BEGIN
SELECT COUNT(*) INTO isPost FROM SDE.STATES WHERE SDE.STATES.STATE_ID=:new.SDE_STATE_ID AND SDE.STATES.LINEAGE_NAME=SDE.STATES.STATE_ID;
IF INSERTING AND (isPost &amp;gt; 0) AND (:new.STATE=0 OR :new.STATE is NULL) THEN
INSERT INTO TEST_TRIGGER (OBJECTID,LOCATION,ID,STATE,TYPE) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUES ( :new.OBJECTID,:new.LOCATION,:new.ID,'NEW','UPDATED');
ELSE IF UPDATING('STATE') AND (:new.STATE=0) AND (:old.STATE=1) AND (isPost &amp;gt; 0) )&amp;nbsp; THEN&amp;nbsp; 
INSERT INTO TEST_TRIGGER (OBJECTID,LOCATION,ID,STATE,TYPE)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUES ( :new.OBJECTID,:new.LOCATION,:new.ID,'NEW','CREATED');
ELSE 
null;
END IF;
END IF;
END;&lt;/PRE&gt;&lt;P&gt;The problem I have here is, I want to capture the update only if they are done on specific columns. When the edits are posted, its always an insert and I won't be able to figure out what its previous value was. I tried writing a before insert trigger and compare with the value from Multi-versioned view but that runs into mutating table problem. [Note: The above script is not optimized, I am just trying to check the possibility of capturing the edit]&lt;/P&gt;&lt;P&gt;Possibly I am doing something wrong here or there is a better way to achieve this. Request help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:43:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/trigger-on-add-table-in-versioned-sde/m-p/864054#M5916</guid>
      <dc:creator>PramodHarithsa1</dc:creator>
      <dc:date>2021-12-12T10:43:52Z</dc:date>
    </item>
  </channel>
</rss>

