Component dbformDescriptionA database record form edits a single record from a database relation.
Usually the form starts up empty and it does not have a current row.
Then a new record can be inserted or an existing record can be searched
for by entering some values. After a successful search the row found
becomes the current row. It can then be modified or deleted.
Format< dbform ... > ... < /dbform > DetailsComponent must not be used inside a form.
Properties
Attributes
Messages
SuperclassThe component inherits Attributes, Methods, and Hookmethods from the following superclasses:
sesform
The ok, success, and ff attributes might be of interest.
panel The ff attribute and the access functions panelobj(n) and panelfield(n) are important. HooksCheckRecord () Is called before a record is stored into the database, either by insert or by update. The method must check the data entered for consistency. It must return an object containing all the fields that should be stored in the database, if everything was ok or deliver an error message as string otherwise. If an error message is issued the database is left unchanged. this.ff contains the form data entered by the user. this.row contains in case of an update the current record in the database otherwise null. In simple cases CheckRecord should just return this.ff, after doing all necessary consistency checks. It can also return a copy of this.ff and add or remove fields to control the data written to the database. A common usage is to automatically calculate key fields. this.ff can also be changed directly, however these changes become visible in the form in case of an error. CheckDelete () is called before a record is deleted from the database. The method must check if the record may be deleted. It must return null, if everything was ok or an error message otherwise. If an error message is issued the database is left unchanged. this.ff contains the form data entered by the user which is normally irrelevant in case of a delete. this.row contains the current record in the database in case of an update, otherwise null. CheckSelect (row) is called before a record becomes the current record of the form. row contains the record just read. The method can return an error message (which leaves the current row unchaged) or null. get_row (row) is called after reading a record into this.row. This happens whenever the form is asked to display a new record and after insert and update operations. The purpose is to prepare the row fields for display. Result of get_row is a tuple that later becomes this.ff. As default get_row returns copy(row). wrapInsert () is wrapped around the insert SQL statement. By default it just contains defbody. Arbitratry code can be inserted before or after the defbody to be executed before or after the SQL statement. wrapUpdate () is wrapped around the update SQL statement. By default it just contains defbody. Arbitratry code can be inserted before or after the defbody to be executed before or after the SQL statement. wrapDelete () is wrapped around the delete SQL statement. By default it just contains defbody. Arbitratry code can be inserted before or after the defbody to be executed before or after the SQL statement. wrap_find_query () is wrapped around the query generation of the find button. That means the defbody returns a string that becomes the search condition of the query to be performed. You can either change the fields in this.ff to modify field values before query generation or you can generate a complete search condition and leave out defbody completely. wrap_lookup_query () is wrapped around the query generation of the lookup button. That means the defbody returns a string that becomes the search condition of the query to be performed. You can either change the fields in this.ff to modify field values before query generation or you can generate a complete search condition and leave out defbody completely. onDuplicate (oldrec) is called if a record with the same key is already present during an Insert operation. Per default this routine returns an appropriate error message. onNotfound () is called if a record searched for is not present. Must return an error message. onDbChange (newrec) is called if current record changed in the database or if it was deleted meanwhile. The routine should call select_row in order to reread the record and return an error message. Alternatively other methods to resolve the conflict can be implemented. The newrec parameter contains the current status of the record. onKeyChange () is called prior to an update if the user changed the key of the current database record. Per default this routine checks the keychange attribute of the dbform and returns an error message if key changes are not allowed. onSuccess () is called on successful completion of an operation Methodsselect_row (search_condition) queries the database according to the search condition. The first record found becomes the current row, unless the CheckSelect hook returns an error message. select_row returns true if a row was found, false if not, and an error message if CheckSelect delivered an error message. insert_row () Performs an insert. update_row () Performs an update. modify_row () Performs an insert or an update depending on weather there is a current row or not. copy_row () Performs a copy, i.e. the form will no longer be associatd with a database record but still contain the same field values. Performing a subsequent insert_row will store the form content as a new database record (assuming that the key field values have been changed to avoid a duplicate record error message). delete_row () Performs a delete. clear () Clears the form. find_row () Search for the first matching row. All fields of a matching row must contain the form field's content as substring. lookup_row () Search for the first matching row. All non-empty form fields must exactly match the row's fields. first_row (direction) Show the first (or last in case direction="backward") record. next_row (direction) Show the next (or previous in case direction="backward") record. © 1996-2024 H.E.I. All Rights Reserved. |
|