Creating New Records with Virtual Widgets

Using the function dal_wdh_wri_lis you can write records in the data base, which were edited (update operation) or newly inserted (insert operation) in DataView. DataView realizes for each records with the help of the content of the internal record ident number, which kind of operation you execute for the data base table.

If you executed an insert operation, DataView assigns a new record ident number. It is automatically entered in the internal ident number field of the mask.

If - because of wrong entries or transaction problems - it is not possible to write a record into the data base, the record-dirty-flag remains set after returning from the function dal_wdh_wri_lis (drt = m). In case of success the record-dirty-flag will be automatically reset by DataView (drt = 0). Using the function dal_mas_ret_drt_rec you can enquire the record-dirty-flag for each record.

Program the following sequence to write newly created records in the data base:

  1. Set the widget virtual mode with the function dal_wdg_set_vir (flg = 1).

  2. Create the widget. For an entity widget, for instance, you would use the function dal_iwf_lis_ent.

    In case of relations widgets you should always specify the full name of the relation (entity-1, entity-2 and view) and then define the parent element of the relation with the function dal_wdg_set_ide.

  3. Create empty records in the mask with the functions dal_mas_cre_rec or dal_mas_ins_row.

    Use dal_mas_ins_row if you want to simultaneously execute the edit_action-trigger of the mask for insert mode and enter defined default values in the fields of the records.

  4. Enter data in the mask using the available standard functions.

    For instance, you could write a field entry with dal_mas_wri_fld. The newly created records do not have any ident number entries, yet.

  5. Set the record-dirty-flags for all changed records with the function dal_mas_set_drt_rec to drt = m.

    In contrast to the update operation you need not set the field-dirty-flags for insert operations, for DataView always has to enter all columns for new records.

  6. Write all changed records of the mask into the data base with the function dal_wdh_wri_lis.

  7. Check whether DataView successfully wrote all records into the data base. To do so, evaluate the return code of the function dal_wdh_wri_lis or inspect the record-dirty-flags with the function dal_mas_ret_drt_rec.

  8. Delete the virtual widget with dal_wdg_del_wdg and deactivate the widget virtual mode with dal_wdg_set_vir (flg = 0).