Hello,
I have been researching creating triggers in SQL to update the edit date and acreage values when an edit is completed on an SDE versioned feature class. I have created the triggers and SQL says that the command is completed successfully, but when I make an edit to the feature class, those fields don't get updated.
I am using SQL Server 2008 R2 Management Studio Express and ArcGIS 10.2.1. The feature class is versioned and I am only using the default version. No other versions were created from that. So, I don't need to reconcile any versions back to the default version. The code I am using is below.
<SPAN class="keyword token">Use</SPAN> <SPAN class="punctuation token">[</SPAN>DNR_SDE<SPAN class="punctuation token">]</SPAN>
GO
<SPAN class="keyword token">SET</SPAN> ANSI_NULLS <SPAN class="keyword token">ON</SPAN>
GO
<SPAN class="keyword token">SET</SPAN> QUOTED_IDENTIFIER <SPAN class="keyword token">ON</SPAN>
GO
<SPAN class="keyword token">CREATE</SPAN> <SPAN class="keyword token">TRIGGER</SPAN> <SPAN class="punctuation token">[</SPAN>DNR_Edit<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">[</SPAN>trg_insert_acres_date_fields<SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">ON</SPAN> <SPAN class="punctuation token">[</SPAN>DNR_Edit<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">[</SPAN>TRIBAL_TRUST_LANDS<SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">AFTER</SPAN> <SPAN class="keyword token">INSERT</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">UPDATE</SPAN>
<SPAN class="keyword token">AS</SPAN>
<SPAN class="keyword token">BEGIN</SPAN>
<SPAN class="keyword token">SET</SPAN> NOCOUNT <SPAN class="keyword token">ON</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">UPDATE</SPAN> <SPAN class="punctuation token">[</SPAN>DNR_Edit<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">[</SPAN>TRIBAL_TRUST_LANDS<SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">SET</SPAN> edit_date <SPAN class="operator token">=</SPAN> getdate<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">WHERE</SPAN> OBJECTID <SPAN class="operator token">IN</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">SELECT</SPAN> OBJECTID <SPAN class="keyword token">FROM</SPAN> INSERTED<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">UPDATE</SPAN> <SPAN class="punctuation token">[</SPAN>DNR_EDIT<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">[</SPAN>TRIBAL_TRUST_LANDS<SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">SET</SPAN> Acres <SPAN class="operator token">=</SPAN> shape<SPAN class="punctuation token">.</SPAN>STArea<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">*</SPAN> <SPAN class="number token">0.000247105</SPAN>
<SPAN class="keyword token">WHERE</SPAN> OBJECTID <SPAN class="operator token">IN</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">SELECT</SPAN> OBJECTID <SPAN class="keyword token">FROM</SPAN> INSERTED<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">END</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Is there a potential delay with a versioned FC before the fields get populated? I know others have used this same coding for an editable GIS web application and it is immediate, but I cannot figure out why it won't work for me.
Also, I would like to have a trigger that would automatically populate the latitude and longitude coordinates for any point added to a feature class or existing point adjusted. Is there any way to do that?
Thanks in advance for any assistance.
Lisa