Subject | Re: can i trim (or upper) value in check constraint ? |
---|---|
Author | emailkamlesh2000 |
Post date | 2004-03-18T06:32:43Z |
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:
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:validate them.
> >Thanks For Reply
> >
> >can i trim (or upper) value in check constraint ?
>
> No, you can't use check constraints to change values, only to
>proper and i
> 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
> >have many fields which required such kind of operation and i wantto do
> >that( trim it and then checking ) in check constraint at domainlevel. so
> >that i dont have to write same code in all triggers.means "compare
>
> You have got it all wrong about check constraints. "Check"
> the input with the predicate and reject it if it doesn't fit". Ifyou want
> to modify inputs, you have to use triggers.(buffer) )
>
>
> >so i wrote following udf which does both
> >(as parameter passes by ref, it trims & propers the same CString
> >and return lengththat do
>
> I'm not going there, sorry. There are already well-tested UDFs
> those things and I sure don't have time to play about with yourUDFs. This
> support list is about database stuff, not for debugging yourcode. Maybe
> someone would like to help you with it **off-list**.
>
> ^heLen