Hy all. I am looking for some advice on the folloiwing topic.
As you are all aware database CHAR(10) is a fixed string of 10 chars.
This means that when such field is loaded from the database into a form field is always presented as a 10 char length string, regardless the actual number of alphanumeric chars (it’s padded with trailing blank up to 10 chars). For instance the string RED, is displayed in a form field as REDssssssssss where s is a single blank space.
The extra trailing blank are confusing the user when he has to modify the field.
For instance, when user replaces RED with GREEN on a web form, he has to backspace and delete all trailing blanks. Moreover the focus is always displayed by browser at the end of the field, not at the start, and this force user to delete all trailing blank.
To avoid the tyring and confusing deleting of trailing blank, the field may be trimmed on the OnLoad event, so RED is displayed on the form without useless trailing spaces.
This works perfectly unless you activate the log modole of SC in the form app.
Even if the user does not press any key, and simply save a record without touching the keyboard, Scriptace log module compares the DB original field (REDssssssssss) with the trimmed one (RED) and consider the missing trimmed blank as a modification of the record (which is in theory correct) and log such modification in the LogModule as soon as the user update the record.
The user complains because he/she has not done any actual modification of the record, it was just a trim of blank made in PHP inside OnLoad event, just for presentation purpose.
Any clue ?
One possibility would be to modify the AdoDB driver in order to remove trailing blank on fetched fields as soon as the field is read from DB and before is passed to SC. In such case there is no need to trim blank on the onLoad event and everythink works.
AdoDB drivers has a flag for Oracle database ( $ADODB_ANSI_PADDING_OFF) that actually does that but it works only for Oracle (I am using IBM DB2) and I dont think it’s a good idea to modify the AdoDB driver.