1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| 1> create rule r as
2> @p like '[0-z][0-z][0-z][0-z]' or
3> @p like '[0-z][0-z][0-z][0-z][0-z]' or
4> @p like '[0-z][0-z][0-z][0-z][0-z][0-z]' or
5> @p like '[0-z][0-z][0-z][0-z][0-z][0-z][0-z]' or
6> @p like '[0-z][0-z][0-z][0-z][0-z][0-z][0-z][0-z]'
7> go
1> create table t (p varchar(9)) -- 9 et pas 8 sinon la regle ne limite pas le nombre de caracteres a 8 (je ne sais pas pourquoi, peut-etre un bug Sybase ?)
2> go
1> sp_bindrule r, 't.p'
2> go
Rule bound to table column.
(return status = 0)
1> insert t values ('1234')
2> insert t values ('12345678')
3> go
(1 row affected)
(1 row affected)
1> insert t values ('123')
2> go
Msg 552, Level 16, State 1:
Server 'SYBASE', Line 1:
A column insert or update conflicts with a rule bound to the column. The command is aborted. The conflict occured in database 'master', table 't', rule 'r', column 'p'.
Command has been aborted.
(0 rows affected)
1> insert t values ('123456789')
2> go
Msg 552, Level 16, State 1:
Server 'SYBASE', Line 1:
A column insert or update conflicts with a rule bound to the column. The command is aborted. The conflict occured in database 'master', table 't', rule 'r', column 'p'.
Command has been aborted.
(0 rows affected) |
Partager