Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Auto-Truncate into VARCHAR
I'm not saying this is necessarily a good idea (I want to loose data?!) -
but, I was wondering if it could be done...!
If I have a table with a VARCHAR2(n) column, and try to insert a string with
> n characters, could I automatically truncate it to n characters before
inserting? I tried to set this up using a trigger but Oracle obviously
checks the data dictionary *before* it runs the trigger and returns
ORA-01401 instead of truncating the text as it sees the initial value of the
insert is too big for the column. Any suggestions to get round this?
Any help much appreciated!