Quote:
|
Originally Posted by r937
i think you'll find that MOD, LEN, and MID are not ANSI SQL functions
|
Fair enough - I was misled by a Google result on "ANSI SQL" leading me to w3schools, which I took to be documenting ANSI SQL.
But my question is - doesn't ANSI SQL have anything
equivalent to these functions? I have no idea, just kind of expected it would. After all, Joe Celko must need to write check constraints to verify his VINs and whatnot? In fact, having now Googled for "celko check substring" and found
this article it appears to be:
Code:
( SUBSTRING (person_Number FROM 1 FOR 1) = 'P'
AND SUBSTRING (person_Number FROM 2 FOR 1) BETWEEN '0' AND '9'
AND SUBSTRING (person_Number FROM 3 FOR 1) BETWEEN '0' AND '9'
AND SUBSTRING (person_Number FROM 4 FOR 1) BETWEEN '0' AND '9'
AND SUBSTRING (person_Number FROM 5 FOR 1) BETWEEN '0' AND '9'
AND SUBSTRING (person_Number FROM 6 FOR 1) BETWEEN '0' AND '9'
)
We don't need to test the maximum length, since the column type does that.