Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

oracle String Manipulation to CHAR datatype

Posted on 2010-11-22
5
Medium Priority
?
455 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to recover a database from a user managed backup
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

636 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