更新关系表中的行

“片段”视图的 EGL 抽屉中的 databaseUpdate 片段是一个 EGL 函数,用于在从 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.