リレーショナル・テーブル内の行の更新

「断片」ビューの EGL ドロワー内の databaseUpdate 断片は、PageHandler からレコードを渡したときに、リレーショナル・テーブルの単一行を更新する関数です。 この断片は、EGL ライブラリーに置かれるよう意図されたものです。この断片を挿入し構成する手順は、次のとおりです。

  1. 断片コードを PageHandler に挿入する。 詳細については、『EGL コード断片の挿入』を参照してください。
  2. {tableName} および {keyColumn} を、表の名前とその主キー列で置き換える。
この断片によって挿入されるコードは、次のとおりです。
Function updateRec(${TableName}New  ${TableName})

  // Function name - call this function 
  // passing the ${TableName} Record as a parameter
  ${TableName}Old ${TableName};   

  // A copy of the Record, used 
  // to lock the table row and to obtain 
  // the existing row values prior to update try 
  ${TableName}Old.${KeyColumn} = 
      ${TableName}New.${KeyColumn};
  get ${TableName}Old forUpdate;  

  // Get the existing row.  
  // Note that if you had custom processing to do, 
  // you would insert your code after this call
  move ${TableName}New to ${TableName}Old byName;

  //Move the updated values to the copy-row
  replace ${TableName}Old;  

  //And replace the row in the database.
  sysLib.commit();

  //Commit your changes to the Database
  onException
    //If the update fails...
    sysLib.rollback();

    // cancel all database updates 
    // (assuming this is permitted 
    // by your database) and call 
    // a custom error handling routine
  end
end

関連するタスク
EGL および JSP ファイルへのコードの断片の挿入

ご利用条件 | フィードバック
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.
(C) Copyright IBM Japan 2005.