Article: AN0001620Updated:
ObjectGears system can be extended on the database level by means of procedures or adding unique indexes in classes (tables).
In certain situations it is necessary to return an error from the database. Hereinafter, there are described possible cases.
Query from a stored procedure
If the query reads data from a stored procedure, you just need to call T-SQL function raiserror in the stored procedure.
raiserror( 'Error description...', 16, 1)
Stored procedures and triggers
Also in these situations function raiserror can be called.
Adding a unique index to a table
ObjectGears system does not support in the current version creation of unique indexes. However, this feature can be implemented on the database level. Add unique index to required columns in the table of the class. Once this index is set up, an error is returned in ObjectGears forms, when the data are in conflict with this index. This error is, however, not user friendly and it is necessary to translate it in a text explaining what happend and what the user should do.
This can be solved by adding a corresponding record into the table DBException. The record should contain code of the SQL error, 1-2 texts, that the error contains (name of the index) and error description. The text of the error can be localized in format used by ObjectGears system. After that a user friendly error will be displayed.