Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Substr not working as expected

525401Oct 17 2016 — edited Oct 18 2016

I've got a source table that has a column with data that is more than 200 characters long that I need to trim down to 200 characters.  Typically this would be as simple as using a substr on the column but I'm seeing very weird behavior that I can't explain.  I updated all rows to be {column_name}=substr({column_name}, 1,200) .  Seems like this has always worked but when I try to load the data into another table I get errors that the data is too big for the columns.  Yet when I try to find any rows still remaining where length({column_name})>200 I get no rows returned.  I'm using a varchar2 column.   If I try to change the column length on the table I just trimmed it also gives me an error that there are rows that are too big.   If I create a temp table off the source table where I use the substr the column data type create is actually varchar2(800), which makes no sense to me. 

Here is my environment info:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

PL/SQL Release 11.2.0.4.0 - Production

"CORE 11.2.0.4.0 Production"

TNS for Linux: Version 11.2.0.4.0 - Production

NLSRTL Version 11.2.0.4.0 - Production

This post has been answered by mathguy on Oct 17 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 15 2016
Added on Oct 17 2016
5 comments
3,180 views