Transferring values of a field from a table to another based on common key applying a trigger,

654
4
02-12-2017 11:49 AM
JamalNUMAN
Esteemed Contributor

Transferring values of a field from a table to another based on common key applying a trigger,

 

As per the screenshot below, I wanted to transfer the values of “enabled” field from T1 table (stored in h.mdf file) to “L1” Layer (stored in m.mdf file) based on the common filed “Ref_S” field. The idea behind is to write the values of T1 into L1 and thus the relation is supposed to be dynamic such that the changes in T1 will be transferred in the real time to L1 so that the values can be represented in terms of map. However, in this case, I’m not sure if the trigger will be directed to the L1 that is under “Table” folder or the one that is under “View”.

 

I would appreciate if anyone can help me out in writing the trigger.

 

Thank you

 

Best

Jamal

----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos
4 Replies
AdamZiegler1
Esri Contributor

Hi - Jamal, Could you expand a little bit on your feature classes? Are T1 and L1 both versioned feature classes? What type of versioning is being used? The evw views are system geneterated views that compile the base table with the delta tables based on a specific version. Default version is used by default, but using SQL other versions can be accessed. The purpose behind the evws is to be able to read or edit a FC using SQL, not ArcMap. So, there are a few variables to consider when you are trying to edit (or enable a trigger against) an evw. You need to know what version is being editied and the versioning methodology used (standard, move-to-base).

What is a versioned view?—Help | ArcGIS Desktop 

-Adam Z

JamalNUMAN
Esteemed Contributor

Hi Adam,

 

I have newly started the discussion here:

https://community.esri.com/message/679453-re-writing-on-a-particular-field-of-a-table-layer-stored-i...

----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos
AhmadSALEH1
Occasional Contributor III

Hi Jamal,

Please give this a try, it worked with me without any issues. In my case I have the following:

  • a F.C with a name “P” and the foreign key (ID) field name is “keyf”
  • Table contains ID field with name “ID”

1-first when register the F.C please check “register the selected objects with option to move the edits to base”

 

2 -go to SQL and write this trigger

create trigger JamalT

on p

after update, insert

as

begin

select * from p

select * from Stat

 

 

UPDATE p

SET     p.enabled=Stat.Status

FROM   P

       INNER JOIN Stat

          ON p.keyf = Stat.ID

 

End

 

3- Start edit session in Arcmap and Add a point for example, then stop editing, you will notice that the “Enabled” field will automatically updated.

JamalNUMAN
Esteemed Contributor

Hi Adam and Ahmad,

 

I wanted to apply this WITHOUT having “move edits to base” option checked. The target feature class is the one housed in the parent version.

 

In my workflow, I need the values that are stored on the table to be transferred to the attribute table of the layer. So, the update starts on the table and then the layer is updated accordingly.

----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos