Solved

oracle String Manipulation to CHAR datatype

Posted on 2010-11-22
5
452 Views
Last Modified: 2012-06-27
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.
0
Comment
Question by:eagle_ea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 34190298
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
 
LVL 6

Expert Comment

by:anumoses
ID: 34190301
What is the length of col1? Make sure its greater than col1|| 'X'
0
 
LVL 6

Expert Comment

by:anumoses
ID: 34190312
You can also use

update table set col1 = trim(rtrim(col1)) || 'X' ;
0
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 34190314
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
 
LVL 6

Expert Comment

by:anumoses
ID: 34190315
update table set col1 = ltrim(rtrim(col1)) || 'X' ;
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question