I don't think there is a solution for you. Column definition doesn't have such properties.
Apparentlly, You don't want to add func, such as substr/char/varchar/cast, in the insert stmt. Even a trigger need such functions to manipulate data.
Another way is truncate the data before insert inside APPLICATION. for example:
DECLARE HV VARCHAR(255)
:HV = truncate(source string...)
INSERT INTO T(COL_VARCHAR_255) VALUES(:HV)
Quote:
|
Originally Posted by ApoPen
Is it possible to define a column to automatically truncate data?
I have a column with length of 255, If i insert anything larger I naturally get an error (SQL0433N). The problem is sometimes (not often) there is data that will be longer.
Can I setup a column to automically truncate this data instead of having to code the trucate funtion on the inserts? Coding truncates on all the inserts on this table is time consuming, and if i change the column length in the future, I then have to go change all my code.
|