Subject | Re: [firebird-support] Inserting into Table needing truncate for varchar |
---|---|
Author | Fabian Chocron |
Post date | 2006-04-18T17:47:33Z |
Ivan,
Thanks a lot for your response.
I would like to write a trigger before insert in order
to convert all Varchar fields into Substring.
Do you know how can I retrieve in runtime the fields
type and size so I can execute something like:
If Field_Type is Varchar then new.myvarchar =
substring (new.myvarchar , 1 , size(new.myvarchar))
I need to do it this way because I cannot rely on the
apps as there are to many programs and programmers.
Thanks a Lot for your help and time,
Fabian
--- Ivan Prenosil <Ivan.Prenosil@...> wrote:
This correspondence is for the named person's use only. It may contain confidential or legally privileged information or both
No confidentiality or privilege is waived or lost by any miss transmission. If you receive this correspondence in error,
please immediately delete it from your system and notify the sender. You must not disclose, copy or rely on any part of this
correspondence if you are not the intended recipient. Any views expressed in this message are those of the individual sender,
except where the sender expressly, and with authority, states them to be the views of: IT Bizolutions Pty. Ltd.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Thanks a lot for your response.
I would like to write a trigger before insert in order
to convert all Varchar fields into Substring.
Do you know how can I retrieve in runtime the fields
type and size so I can execute something like:
If Field_Type is Varchar then new.myvarchar =
substring (new.myvarchar , 1 , size(new.myvarchar))
I need to do it this way because I cannot rely on the
apps as there are to many programs and programmers.
Thanks a Lot for your help and time,
Fabian
--- Ivan Prenosil <Ivan.Prenosil@...> wrote:
> >>I have an App that uses "Insert into Table SelectFabian Chocron
> Varchar ....
> >>
> >>The problem is that sometimes the Varchar is
> "bigger" than the defined
> >>receiving field. Is there any way to "truncate on
> the fly"... so the
> >>app can insert regardless of the size of the
> "selected" field?
> >
> > Yes. Use CAST( aVarchar as Varchar(n)), where n
> is the size of the
> > target column.
>
> CAST can't truncate string (only if cut characters
> are spaces).
>
> CAST is done implicitly in "Insert into Table Select
> Varchar",
> so you know it can't work.
>
> Ivan
>
> >
> > An alternative is to use the internal function
> SUBSTRING() to limit
> > the size of the string, viz. SUBSTRING(aVarchar
> from 1 for n) where,
> > again, n is the size of the target column.
>
>
>
This correspondence is for the named person's use only. It may contain confidential or legally privileged information or both
No confidentiality or privilege is waived or lost by any miss transmission. If you receive this correspondence in error,
please immediately delete it from your system and notify the sender. You must not disclose, copy or rely on any part of this
correspondence if you are not the intended recipient. Any views expressed in this message are those of the individual sender,
except where the sender expressly, and with authority, states them to be the views of: IT Bizolutions Pty. Ltd.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com