oracle String Manipulation to CHAR datatype

Hello,
running the below statement does not work,

update table set col1 = col1 || 'X' ;

col1 is of CHAR datatype.

the error i'm getting is " value too large". i understand CHAR allocates the specified length as defined. would append not work at all??

could someone please help.
eagle_eaAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
you need to first trim off the trailing spaces...

note: your columns should eventually be in VARCHAR2 instead of CHAR ...

update table set col1 = trim(col1) || 'X' ;

Open in new window

0
 
anumosesCommented:
What is the length of col1? Make sure its greater than col1|| 'X'
0
 
anumosesCommented:
You can also use

update table set col1 = trim(rtrim(col1)) || 'X' ;
0
 
cyberkiwiCommented:
anumoses,
" What is the length of col1? Make sure its greater than col1|| 'X'  "

That is impossible!
Col1 is char, so col1||X will always be len(col1) + 1!
Hence TRIM proposed by Angel.

But if col1 is full, then the statement wills till fail.
0
 
anumosesCommented:
update table set col1 = ltrim(rtrim(col1)) || 'X' ;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.