Saturday, October 4, 2008

Validating your Data Entry for Trailing Blanks

Today, I would like to experiment the use of CHECK constraint to validate the trailing blanks in the data.
Example,


demo$Vino%orcl> create table t(name varchar2(20)
2 check (length(name)-length(trim(name))=0));

Table created.
demo$Vino%orcl> insert into t values('Tom'); 1 row created.
demo$Vino%orcl> insert into t values('Tom Peter'); 1 row created.
demo$Vino%orcl> -- Name with trailing blanks
demo$Vino%orcl> insert into t values('Tom '); insert into t values('Tom ') * ERROR at line 1: ORA-02290: check constraint (DEMO.SYS_C005409) violated
demo$Vino%orcl> select * from t;
NAME ---------- Tom Tom Peter
Hope this will be useful for you :-)

1 comment:

Mythili Varadarajan said...

can u explain the syntax and usage of Connect By ?