Subject | Re: [firebird-support] Inserting into Table needing truncate for varchar |
---|---|
Author | Ivan Prenosil |
Post date | 2006-04-18T12:51:30Z |
>>I have an App that uses "Insert into Table Select Varchar ....CAST can't truncate string (only if cut characters are spaces).
>>
>>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 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.