Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

トリガーの使用例

例1:現在の勘定残高を計算する

No Format
Object           
Code Block
Object           : Account (ACNT)
Trigger Field    Field    : "Account Balance" (ACCBAL)      
Trigger Method   Method   : Calculates the current balance of the account. 
Trigger Event(s) : 1. AFTER READ when ACCBAL is REF (referenced)    
Invoked By       By       : (i.e. How is an account balance retrieved ?)
                       FETCH                      FETCH FIELDS(....#ACCBAL....)
                            FROM                            FROM_FILE(ACNT)
                 or                 or SELECT FIELDS(....#ACCBAL....)
                            FROM                            FROM_FILE(ACNT)    
Comments         Comments         : Quite efficient because ACCBAL is only
                   calculated                   calculated when the requester asks for it.

例2:注文のバッチ印刷ジョブを送信する

No Format
Object           
Code Block
Object           : Order (ORDR)
Trigger Field    Field    : "Print Required" (PRINT_REQ)    
Trigger Method   Method   : Submits batch order print job. Batch function
                   prints                  prints order and updates PRINT_REQ to 'N'.    
Trigger Event(s) : 1. AFTER INSERT when PRINT_REQ EQ  EQ  'Y'
                   2                  2. AFTER UPDATE when PRINT_REQ EQ  EQ  'Y'
                                   and  PRINT                                  and  PRINT_REQ NEP PRINT_REQ    
Invoked By       By       : (i.e. How is an order submitted for printing ?)
                   CHANGE                   CHANGE #PRINT_REQ 'Y'
                   UPDATE                  UPDATE FIELD(#PRINT_REQ) IN_FILE(ORDR)    
Comments         Comments         : It may seem a little obscure as an IBM i
                   based                 based trigger but what if the update
                   comes                  comes from a PC based application via
                   the                   the LCOE facility, or from a batch job
                   that                  that starts automatically every morning
                   and                   and automatically selects certain
                   orders                  orders for printing ?