<?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>Question Re: Trigger Computed column refresh in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaa-p/13849173#M4880016</link>
    <description>&lt;P&gt;In the help, in section SQL Anywhere Server - SQL Usage » Database objects » Computed columns » Recalculating computed columns, it states:&lt;/P&gt;
&lt;P&gt;Computed columns are not recalculated under the following circumstances: &lt;/P&gt;
&lt;P&gt;The computed column is queried.&lt;/P&gt;
&lt;P&gt;The computed column depends on the values of other rows (using a subquery or user-defined function), and these rows are changed.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Sep 2011 09:34:36 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-09-30T09:34:36Z</dc:date>
    <item>
      <title>Trigger Computed column refresh</title>
      <link>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaq-p/13849167</link>
      <description>&lt;P&gt;I have 2 tables (parent and child).
On parent, I have a computed column that is sum of ColA in Child table by parent id.&lt;/P&gt;
&lt;P&gt;My problem is: how to refresh computed column value when I have a insert/delete on child table?
I don't need to process updates since my program doesn't allows it. &lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2011 10:22:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaq-p/13849167</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-29T10:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Trigger Computed column refresh</title>
      <link>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaa-p/13849168#M4880011</link>
      <description>&lt;P&gt;Is this really a computed column, i.e. declared with COMPUTE(...)?&lt;/P&gt;
&lt;P&gt;AFAIK, those should only be used with constant values and deterministic functions.&lt;/P&gt;
&lt;P&gt;I would generally recommend to omit (or "delay") the computation completely by using a view instead of a computed column, say by something like &lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="n"&gt;create&lt;/SPAN&gt; &lt;SPAN class="n"&gt;view&lt;/SPAN&gt; &lt;SPAN class="n"&gt;V_ParentWithSum&lt;/SPAN&gt; &lt;SPAN class="n"&gt;as&lt;/SPAN&gt;
&lt;SPAN class="nb"&gt;select&lt;/SPAN&gt; &lt;SPAN class="n"&gt;parent&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.*&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;child&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;colA&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="n"&gt;as&lt;/SPAN&gt; &lt;SPAN class="n"&gt;SummedChild&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;from&lt;/SPAN&gt; &lt;SPAN class="n"&gt;parent&lt;/SPAN&gt; &lt;SPAN class="n"&gt;key&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;join&lt;/SPAN&gt; &lt;SPAN class="n"&gt;child&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;If this does not need your requirements, I would use a trigger on child to update the parent. But then I would &lt;EM&gt;not&lt;/EM&gt; declare the column as a computed column, as changing computed columns via triggers of other tables &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbusage/inserting-computed-javause.html"&gt;seems dangerous&lt;/A&gt; (and looks suspicious as well IMHO).&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2011 10:35:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaa-p/13849168#M4880011</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2011-09-29T10:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Trigger Computed column refresh</title>
      <link>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaa-p/13849169#M4880012</link>
      <description>&lt;P&gt;Use after insert, update and delete triggers like:&lt;/P&gt;
&lt;P&gt;create TRIGGER "AInsert" after insert on
child
referencing new as new_row&lt;/P&gt;
&lt;P&gt;create TRIGGER "AUpdate" after update of ColA,
order 1 on child
referencing new as new_row&lt;/P&gt;
&lt;P&gt;create TRIGGER "ADelete" after delete order 1 on
child 
referencing old as old_row&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2011 11:35:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaa-p/13849169#M4880012</guid>
      <dc:creator>MCMartin</dc:creator>
      <dc:date>2011-09-29T11:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: Trigger Computed column refresh</title>
      <link>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaa-p/13849170#M4880013</link>
      <description>&lt;P&gt;what?! I don't understand! I know how to work with triggers, but I need a way to refresh computed column values when rows are inserted/deleted on another table!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2011 20:52:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaa-p/13849170#M4880013</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-29T20:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Trigger Computed column refresh</title>
      <link>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaa-p/13849171#M4880014</link>
      <description>&lt;P&gt;I just wanted to give you a starter on how to work with a trigger to solve your problem.
I didn't thought, that you were using the term computed column in its technical way, in that case Volkers answer is more appropriate.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2011 03:02:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaa-p/13849171#M4880014</guid>
      <dc:creator>MCMartin</dc:creator>
      <dc:date>2011-09-30T03:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Trigger Computed column refresh</title>
      <link>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaa-p/13849172#M4880015</link>
      <description>&lt;P&gt;As stated in my answer, I would not recommend to do so if this column is really "computed".&lt;/P&gt;
&lt;P&gt;How is the column declared - do you use an UDF to sum up the childs?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2011 06:59:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaa-p/13849172#M4880015</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2011-09-30T06:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Trigger Computed column refresh</title>
      <link>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaa-p/13849173#M4880016</link>
      <description>&lt;P&gt;In the help, in section SQL Anywhere Server - SQL Usage » Database objects » Computed columns » Recalculating computed columns, it states:&lt;/P&gt;
&lt;P&gt;Computed columns are not recalculated under the following circumstances: &lt;/P&gt;
&lt;P&gt;The computed column is queried.&lt;/P&gt;
&lt;P&gt;The computed column depends on the values of other rows (using a subquery or user-defined function), and these rows are changed.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2011 09:34:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/trigger-computed-column-refresh/qaa-p/13849173#M4880016</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-30T09:34:36Z</dc:date>
    </item>
  </channel>
</rss>

