Subject Re: [ib-support] Which way would be best ?
Author Doug Chamberlin
At 10/20/2001 09:15 PM (Saturday), bossman@... wrote:
>So I'm wondering for ease of validation and support would one do the
>validation on the client or the server ?
>
>If the answer is the server side then validation is to be done via
>Stored procedure or trigger ??

If I understand correctly, you want to check if either the street address
or PO Box are entered and that the location is entered.

If that's all you want to validate then I don't think there is an issue
with "ease of validation and support". Here are some relevant issues: Put
the validation in one place only if you can. This means on the client in a
ValidateData method which can be called from the TButton.OnClik handler or
elsewhere. (The Windows Way is to call this from the OnChange handler for
the street address, PO Box, and Location edit controls and enable the Close
button only when the data is fully valid.)

Te biggest reason to perform this validation at the server is if the
database will be accessed by other software than your application. In that
case you want ALL applications to perform the same validation in order to
ensure the integrity of the data. However, you will need to add it to both
a BEFORE INSERT trigger and a BEFORE UPDATE trigger. It will be messier to
use a stored procedure due to the limitations of passing parameters to
stored procedures (you cannot pass the whole record and let the stored
procedure decide which fields it wants to examine). Therefore, your code
will be duplicated.

Also, if the validation is done at the server you will need to define an
exception which can be detected back at the client when the validation
fails. You will then need to pay attention to transaction handling back in
the client to rollback after the exception occurs.

Overall, much easier to do the validation on the client in the OnChange
handlers. Be sure to document for the user why the Close button is not
enabled when they think it should be!

Delphi 2.0? Wow!