Was this helpful?
Using Unloadtable with Database Access
The QUEL application in the following example uses the _state constant and an unloadtable statement to update a database with mailing list information:
"Writelist" =
begin
  range of m is mailtable;
  unloadtable maillist (rowstat = _state)
  begin
    if rowstat = 1 then
      /* Add row to database */
      append mailtable 
        (name = maillist.name, 
        address = maillist.address, 
        city = maillist.city,
        state = maillist.state);
    elseif rowstat = 3 then
      /* update the row in the database */
      replace m (name = maillist.name,
        address = maillist.address, 
        city = maillist.city,
        state = maillist.state)
        where m.name = maillist.old;
    elseif rowstat = 4 then
      /* delete the row from the database */
      delete m where m.name = maillist.old;
    endif;
  end;
end
When this application is running, the user can choose Writelist from the menu to write changes back to the database. Ingres performs the appropriate database operation, depending on the value of the _state constant.
The key for the replace and delete statements is the table field's hidden column Old, which contains the value of the database column Name that was originally loaded from the database. The updated row must be identified by its previous contents.
Last modified date: 04/03/2024