Version 3 Technical Highlights - ValidateName

Published ByDateVersionKnowledge LevelKeywords
Sprezzatura Ltd01 NOV 19923.0+EXPERTVALIDATENAME, @FILE.ERROR, SQL

This is a function designed to check whether a given name will conflict with SQL/system reserved words or rules. It is passed the name to validate and a Boolean flag which is used to indicate whether changes are permitted (true for yes, false for no). It returns either the word, the modified word or a pass/fail flag.

If changes are permitted the system will modify SQL reserved words or variables beginning with an integer by putting an "A" at the beginning (try using KEY as a column name in DEFINETABLE to see an example of this). It will also truncate names longer than 50 characters and convert lowercase to uppercase.

If changes are not permitted it will return a true/false flag to indicate whether the name conforms to SQL naming conventions. If a false flag is returned the reason is given in @FILE.ERROR, with return codes ranging from S110 to S115, with meanings as follows

S110Starts with a number
S111Longer than 50 characters
S112Contains invalid characters
S113Reserved by the system (in testing it proved impossible to produce this message with SYS table names or VOC commands)
S114Reserved by SQL
S115Does not start with a letter (could only get this to fail if the name started with an underscore. All other characters caused an S112.

(Volume 4, Issue 6, Page 7)