Was this helpful?
Unloadtable (QUEL)
Unloads the contents of the data set underlying a table field.
QUEL examples are given below. See Unloadtable for a description of the unloadtable statement.
Examples (QUEL Only)
Use unloadtable with pattern matching to scroll the table field to the first row whose data starts with the characters the user specified. If the user enters "Smith" the pattern is set to "Smith*" and retrieves the first row beginning with the name Smith, Smithson, Smithburg, etc. The display then scrolls to the retrieved row.
pattern := name + "*";
unloadtable emp (row = _record) 
begin
  if emp.name like pattern then
    scroll emp to row ;
  endif;
end;
The example below updates a mailing list on the basis of the _state of each data set row. The hidden table-field column called maillist.old is the key to the updating, because it contains the original value of the Name field when the row was originally loaded from the database into the data set:
"Writelist" = 
begin 
  unloadtable maillist (rowstat = _state)
  begin
    if rowstat = 1 then
      /* Add row to database */
      repeat append mailtable 
        (name = maillist.name,
        address = maillist.address, 
        city = maillist.city,
        state = maillist.state);

    elseif rowstat = 3 then
      /* Update the row in the database */
      repeat replace mailtable
        (name = maillist.name,
        address = maillist.address,
        city = maillist.city,
        state = maillist.state) 
        where mailtable.name = 
          maillist.old;
    elseif rowstat = 4 then
      /* Delete the row from the */ 
      /* database */
      repeat delete mailtable
        where mailtable.name = 
          maillist.old;
    endif;
  end;
Last modified date: 08/28/2024