Solved

oracle String Manipulation to CHAR datatype

Posted on 2010-11-22
5
453 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

695 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