Solved

oracle String Manipulation to CHAR datatype

Posted on 2010-11-22
5
449 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
  • 3
5 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
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
Comment Utility
What is the length of col1? Make sure its greater than col1|| 'X'
0
 
LVL 6

Expert Comment

by:anumoses
Comment Utility
You can also use

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

Expert Comment

by:cyberkiwi
Comment Utility
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
Comment Utility
update table set col1 = ltrim(rtrim(col1)) || 'X' ;
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Via a live example, show how to take different types of Oracle backups using RMAN.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now