|
Object hooks
Object hooks are used for checking the logic integrity of objects (that is, records in a table).
Object hooks replace the before.read, after.read, before.write, after.write, before.rewrite, after.rewrite, before.delete, and after.delete subsections in the main.table.io section of the UI script.
If there is a DAL for an object set, the 4GL engine calls the object hooks in the DAL every time that a DAM is executed for that object set. The object hooks perform the necessary checks to ensure the logical integrity of the objects being accessed. Any of the above mentioned sections in the UI script are ignored. So, if a UI script contains any of these sections, you must replace these by object hooks in the DAL.
Available object hooks
Return values and errors
Only the before hooks can prevent a database action. The after.get.object() hook can prevent a record from being sent to the UI. Both these types of hook block continuation of the calling method if the return value is set to DALHOOKERROR (a negative constant). If the return value is zero, the method continues.
The following table indicates how return values and error messages are handled. The STP column indicates how the 4GL engine reacts if a hook returns a DALHOOKERROR. The Messages column indicates what happens to messages when an error occurs. The Warnings column indicates what happens to messages when no error is returned. The DAM column indicates how Data Access Methods react when an error occurs.
|
before.open.object.set()
|
exit
|
display
|
display
|
return
|
|
before.get.object()
|
ignore
|
ignore
|
ignore
|
return
|
|
after.get.object()
|
skip
|
ignore
|
ignore
|
return
|
|
before.destroy.object()
|
return
|
display
|
display
|
return
|
|
after.destroy.object()
|
ignore
|
ignore
|
ignore
|
return
|
|
before.save.object()
|
return
|
display
|
display
|
return
|
|
after.save.object()
|
ignore
|
ignore
|
ignore
|
return
|
Related topics
|