The databaseUpdate snippet in the EGL drawer of the Snippets view is a function that updates a single row of a relational table when passed a record from a PageHandler. This snippet is intended to be placed in an EGL library. To insert and configure this snippet, follow these directions:
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
Related tasks
Inserting code snippets into EGL and JSP files