I have input data coming from a flat file which has english, japanese, chinese characters in one column.
I am loading these values in a staging table column whose schema definition is VARCHAR2(250 CHAR), the main table column has definition VARCHAR2(250) WHICH i can not change.
So, i am doing a SUBSTR on this column. After loading the table when i did a
SELECT * FROM TABLE
…I get this error :
ORA-29275: partial multibyte character
If i select other columns then no issues.
you should use
SUBSTRBwhen you copy your data from your250 CHARcolumn to your250 bytecolumn. This function will only output whole characters (you won’t get incomplete unicode characters):Edit:
@mwardm made an interesting comment concerning the actual length of the resulting string and whether the resulting string could contain an invalid sequence of bytes. Consider the following on an AL32UTF8 DB:
As you can see the last byte of the
substrbstring is not the truncated first byte of the special character but encodes a legit character (The first 128 characters in this character set are the same as the ASCII7US character set so this encodes the' 'space character, using RTRIM as suggested in another answer will remove the last character).Furthermore, I also got this interesting result using the character set AL16UTF16:
In this case Oracle has choosen to cut the string after the second byte because in the AL16UTF16 character set there is no legit one-byte character. The resulting string is only 2 bytes instead of 3.
This would need further testing and is by no mean a rigorous demonstration but I still stand by my first hunch that
substrbwill return a valid sequence of bytes that encodes a valid string of characters.