Subject RE: [firebird-support] can i use UDFs with CHECK constraint (trigger) ?
Author Thomas Steinmaurer
Hi,

> i m having many fields in many tables which are required to have some
> minimum length strings
>
> so i thought to define DOMAIN for such kind of field, like following
>
> CREATE DOMAIN CODENAME VARCHAR(50) CHECK ( strlen( Value ) > 5 ) );
>
> but it generates error,
>
> is there any way to use UDFs in CHECK constraints , so that i dont have to
> write same code in all triggers

Omit the last right parenthesis. That is one too much. ;-)

Assumed you have strlen in your database declared, the
following should work.

CREATE DOMAIN CODENAME VARCHAR(50) CHECK ( strlen( Value ) > 5 )


If you don't want to use an UDF for that, then the
following might work as well:

CREATE DOMAIN CODENAME AS
VARCHAR(50)
CHECK (VALUE LIKE '______%')
;



HTH,
Thomas Steinmaurer
LogManager Serie - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database and MS SQL Server
Upscene Productions
http://www.upscene.com