title: Under what conditions would a Sybase trigger not be called?
body: <p>I have a couple of triggers in a Sybase ASE database that are fired upon updates to two tables: Docs and Trans. </p>
  
  <p>The triggers are defined as shown here:</p>
  
  <p>For Docs:</p>
  
  <pre><code> CREATE TRIGGER dbo.Index_Change_Docs
   ON dbo.docs
   FOR INSERT,UPDATE AS
  
   IF UPDATE(DOCTYPE) OR UPDATE(BATCH_NO) OR UPDATE(SCANDATE) OR           
   UPDATE(PERIOD_START_DATE) OR UPDATE(PERIOD_END_DATE) 
   OR UPDATE(DISPATCH_ID) OR UPDATE(DISPATCH_NAME) OR UPDATE(CHECKNUM) OR    
   UPDATE(CHECKAMT)
   BEGIN
      INSERT INTO 
      DOCID_SYNC (IS_DOC_ID, CRTN_DT, SYNC_STATUS_CDE) 
      SELECT Inserted.DOCID, GETDATE(), "N" FROM Inserted
  
   END
  </code></pre>
  
  <p>For Trans:</p>
  
  <pre><code> CREATE TRIGGER dbo.Index_Change_Trans
   ON dbo.Trans
   FOR INSERT,UPDATE AS
  
   IF UPDATE(TRANSNUM) OR UPDATE(CONTRACT) OR UPDATE(FRANCHISE) OR UPDATE(SSN) OR      
   UPDATE(STATE_CODE) OR UPDATE(TRANSTYPE)
  OR UPDATE(AGENCYNUM) OR UPDATE(LOCKBOXBATCHNUM) OR UPDATE(PRODUCTCODE) 
   BEGIN
  
      INSERT INTO 
      DOCID_SYNC (IS_DOC_ID, CRTN_DT, SYNC_STATUS_CDE)
      SELECT DOCID, GETDATE(), "N" FROM DOCS
      WHERE Transnum = (SELECT Inserted.TransNum from Inserted)
   END
  </code></pre>
  
  <p>It appears the behavior of these triggers is different, depending on how updates to those tables are made.</p>
  
  <p>In one case, these tables are updated via two stored procedures (Insert_Docs_SP and Insert_Trans_SP). When this happens, each trigger is fired once (once for Docs, one for Trans) and everything works as expected.</p>
  
  <p>In another case, these tables are updated within a Sybase transaction with two database updates. Here, the first update is done via inline SQL in the calling application (which fires the Trans trigger.) The second update is done via a stored procedure - Insert_Docs_SP, the same as in the other case - which does not fire a trigger.</p>
  
  <p>Perhaps there is something about how transactions are handled that I am not understanding?</p>