Subject Re: can i trim (or upper) value in check constraint ?
Author emailkamlesh2000
Thanks Helen

and sorry for my long boring question

i didnt want to debug my code as i already mentioned that it works
well. (in application)

i just wanted to know whats going different at firebird level.

as u said i tried following in trigger -

// this works well
New.FieldName = Trim( New.FieldName );

// but i can not modify the field content directly
iLength = TrimItAndReturnLength( New.FieldName );


why i can not modified the field content if it is passed by
reference ?


Regards
Kamlesh



--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
> At 09:42 AM 18/03/2004 +0530, you wrote:
> >Thanks For Reply
> >
> >can i trim (or upper) value in check constraint ?
>
> No, you can't use check constraints to change values, only to
validate them.
>
> e.g.
>
> create domain trimmedvartext as varchar(20)
> check (value = upper(value) and value = f_lrtrim(value))
>
> will throw an exception if someone tries to enter ' eastereggs '
>
>
> >actually all i want is to trim field value and make it upper or
proper and i
> >have many fields which required such kind of operation and i want
to do
> >that( trim it and then checking ) in check constraint at domain
level. so
> >that i dont have to write same code in all triggers.
>
> You have got it all wrong about check constraints. "Check"
means "compare
> the input with the predicate and reject it if it doesn't fit". If
you want
> to modify inputs, you have to use triggers.
>
>
> >so i wrote following udf which does both
> >(as parameter passes by ref, it trims & propers the same CString
(buffer) )
> >and return length
>
> I'm not going there, sorry. There are already well-tested UDFs
that do
> those things and I sure don't have time to play about with your
UDFs. This
> support list is about database stuff, not for debugging your
code. Maybe
> someone would like to help you with it **off-list**.
>
> ^heLen