<?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: Informations inside trigger in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849155#M4879998</link>
    <description>&lt;P&gt;You can use the UPDATING() function here which expects the column name as string whereas UPDATE() expects an identifier.&lt;/P&gt;
&lt;P&gt;For an example, see the second FAQ I cited in my answer.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Oct 2018 07:03:09 GMT</pubDate>
    <dc:creator>VolkerBarth</dc:creator>
    <dc:date>2018-10-24T07:03:09Z</dc:date>
    <item>
      <title>Informations inside trigger</title>
      <link>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaq-p/13849152</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Can I get information about the connection that fired the trigger ? Especially the connection name.&lt;/P&gt;
&lt;P&gt;On an after update trigger can I get the name of the column(s) that are updated ?&lt;/P&gt;
&lt;P&gt;Thanks in advence.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 12:10:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaq-p/13849152</guid>
      <dc:creator>former_SQLA_member1694891</dc:creator>
      <dc:date>2018-10-16T12:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Informations inside trigger</title>
      <link>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849153#M4879996</link>
      <description>&lt;P&gt;You can get the connection name via connection_property('Name'). &lt;/P&gt;
&lt;P&gt;For the second question, see &lt;A href="https://sqlanywhere-forum.sap.com/questions/31890/determine-the-columns-that-have-been-modified-in-a-row-in-a-table"&gt;that FAQ&lt;/A&gt; and &lt;A href="https://sqlanywhere-forum.sap.com/questions/26015/identify-updated-column-in-trigger"&gt;that&lt;/A&gt;. &lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 14:06:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849153#M4879996</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2018-10-16T14:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Informations inside trigger</title>
      <link>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849154#M4879997</link>
      <description>&lt;P&gt;Thanks for you reply.&lt;/P&gt;
&lt;P&gt;I try your method to know witch culomn is updated but it seems that the "If UPDATE(col) Then" works only if we pass the column name and not a variable with the column name.&lt;/P&gt;
&lt;P&gt;I try that but it dont pass inside the IF :&lt;/P&gt;
&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;&lt;/SPAN&gt;FOR lpp AS ColCurs CURSOR FOR SELECT cname FROM sys.SYSCOLUMNS WHERE Creator = 'DBA' AND tname = 'CLI'
DO
    SET wCol = cname;
    IF UPDATE(wCol) THEN
        SET wValAv = 'AV';
        SET wValAp = 'Ap';
    END IF;
END FOR;
&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 24 Oct 2018 06:34:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849154#M4879997</guid>
      <dc:creator>former_SQLA_member1694891</dc:creator>
      <dc:date>2018-10-24T06:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Informations inside trigger</title>
      <link>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849155#M4879998</link>
      <description>&lt;P&gt;You can use the UPDATING() function here which expects the column name as string whereas UPDATE() expects an identifier.&lt;/P&gt;
&lt;P&gt;For an example, see the second FAQ I cited in my answer.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 07:03:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849155#M4879998</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2018-10-24T07:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Informations inside trigger</title>
      <link>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849156#M4879999</link>
      <description>&lt;P&gt;I try "IF UPDATING(wCol) THEN", but I have an -143 Syntax error near 'wCol'. Here wCol is a long nvarchar.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 13:19:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849156#M4879999</guid>
      <dc:creator>former_SQLA_member1694891</dc:creator>
      <dc:date>2018-10-24T13:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Informations inside trigger</title>
      <link>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849157#M4880000</link>
      <description>&lt;P&gt;Hm, in my tests with 17.0.9.4857, I could avoid the syntax error but within a cursor loop, the UPDATE search condition does not seem to work properly.&lt;/P&gt;
&lt;P&gt;Here's my attempt with a trigger on the sample database's Products table, with several debug messages within:&lt;/P&gt;
&lt;PRE&gt;create or replace trigger TU_Products
   after update on GROUPO.Products
   referencing old as o new as n
for each row 
begin
   message 'Trigger "TU_Products" fired' to log;
   for lpp as crs cursor
      for select column_name as @ColName
          from SYS.SYSTABCOL SC key join SYS.SYSTAB
          where creator = user_id('GROUPO') and table_name = 'Products'
          order by column_id
      for read only
   do
      message 'Trigger "TU_Products" checks whether column "' || @ColName || '" was modified.' to log;
      if update(@ColName) then
         message 'Trigger "TU_Products": Column "' || @ColName || '" was modified.' to log;
      end if;
   end for;
   if update(Quantity) then
      message 'Trigger "TU_Products": Column "' || 'Quantity' || '" was modified.' to log;
   end if;
   message 'Trigger "TU_Products" finished' to log;
end;

-- Update one row
update Products
set Quantity = Quantity - 1, UnitPrice = UnitPrice + 0.50
where ID = 300;
-- display the last 11 log messages
select msg_text from sa_server_messages(null, -11) order by msg_id;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Oct 2018 04:15:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849157#M4880000</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2018-10-25T04:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Informations inside trigger</title>
      <link>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849158#M4880001</link>
      <description>&lt;P&gt;The test shows the following output:&lt;/P&gt;
&lt;PRE&gt;Trigger "TU_Products" fired
Trigger "TU_Products" checks whether column "ID" was modified.
Trigger "TU_Products" checks whether column "Name" was modified.
Trigger "TU_Products" checks whether column "Description" was modified.
Trigger "TU_Products" checks whether column "Size" was modified.
Trigger "TU_Products" checks whether column "Color" was modified.
Trigger "TU_Products" checks whether column "Quantity" was modified.
Trigger "TU_Products" checks whether column "UnitPrice" was modified.
Trigger "TU_Products" checks whether column "Photo" was modified.
Trigger "TU_Products": Column "Quantity" was modified.
Trigger "TU_Products" finished

&lt;/PRE&gt;

&lt;P&gt;Apparently, the "if update(@ColName)" test did not succeed for the "Quantity" column whereas the test via "if update(Quantity)" does - as does the test via the alternate syntax with "if updating('Quantity')".&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 04:17:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849158#M4880001</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2018-10-25T04:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: Informations inside trigger</title>
      <link>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849159#M4880002</link>
      <description>&lt;P&gt;There is no column named @ColName so UPDATE ( @ColName ) might be expected to return false.&lt;/P&gt;
&lt;P&gt;I don't know if EXECUTE IMMEDIATE will work, but it's the next Dead Chicken to try &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 10:39:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849159#M4880002</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2018-10-25T10:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: Informations inside trigger</title>
      <link>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849160#M4880003</link>
      <description>&lt;P&gt;Well, being on v17, I had tried with the cool indirect identifier feature but could not provide valid syntax...&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 11:13:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849160#M4880003</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2018-10-25T11:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Informations inside trigger</title>
      <link>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849161#M4880004</link>
      <description>&lt;P&gt;The replies are hidden &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 12:48:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849161#M4880004</guid>
      <dc:creator>former_SQLA_member1694891</dc:creator>
      <dc:date>2018-10-25T12:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Informations inside trigger</title>
      <link>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849162#M4880005</link>
      <description>&lt;P&gt;Hm? What do you mean?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 14:11:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/informations-inside-trigger/qaa-p/13849162#M4880005</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2018-10-25T14:11:10Z</dc:date>
    </item>
  </channel>
</rss>

