Home » SQL & PL/SQL » SQL & PL/SQL » pad/fill blank spaces (merged 4 topics)
pad/fill blank spaces (merged 4 topics) [message #316054] Wed, 23 April 2008 10:25 Go to next message
shoaib123
Messages: 118
Registered: December 2007
Location: Chicago
Senior Member

If i need to add blank spaces to a null column, how can i do that.. I have tried using rpad function.. but it does not work out for null values.

[Updated on: Wed, 23 April 2008 10:26]

Report message to a moderator

Re: Pad blank spaces [message #316056 is a reply to message #316054] Wed, 23 April 2008 10:28 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Did you take the time to read this sticky before posting?
adding blank spaces [message #316058 is a reply to message #316054] Wed, 23 April 2008 10:31 Go to previous messageGo to next message
shoaib123
Messages: 118
Registered: December 2007
Location: Chicago
Senior Member

If i need to add blank spaces to a null column, how can i do that.. I have tried using rpad function.. but it does not work out for null values. I know we can use the nvl function for this.. but is there any alternate way to add, because in some cases i might need to add more 50 spaces..
Re: Pad blank spaces [message #316059 is a reply to message #316056] Wed, 23 April 2008 10:34 Go to previous messageGo to next message
shoaib123
Messages: 118
Registered: December 2007
Location: Chicago
Senior Member

So, as per frank correction .. i have added this question at sql newbie. Please frank take some time there to answer this question.. I know there is way to do that using nvl function.. i am looking for alternate way, because i need to add more than 50 spaces to some null column values..

Appreciated Frank
Re: Pad blank spaces [message #316061 is a reply to message #316059] Wed, 23 April 2008 10:40 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
So, apparently you cannot rpad a null.
Change the null to a space then. Use nvl for that.
Re: Pad blank spaces [message #316062 is a reply to message #316061] Wed, 23 April 2008 10:47 Go to previous messageGo to next message
shoaib123
Messages: 118
Registered: December 2007
Location: Chicago
Senior Member

Really appreciate your time.. I am not sure, why i did not think to do this way.. You were right that was simple..

fill blank spaces (merged 3) [message #316324 is a reply to message #316054] Thu, 24 April 2008 11:21 Go to previous messageGo to next message
shoaib123
Messages: 118
Registered: December 2007
Location: Chicago
Senior Member

I need to hard code some column values as empty spaces in my program. That empty spaces might be 40 length long.. i know there is one to do it.. let's say if i need to print out a column with 3 spaces as empty ..

select ' ' as col from dual.

I am wondering .. is there any alternate way to do this .. because some fields are longer 40 length long to print out as empty...
fill blank spaces [message #316325 is a reply to message #316324] Thu, 24 April 2008 11:25 Go to previous messageGo to next message
shoaib123
Messages: 118
Registered: December 2007
Location: Chicago
Senior Member

I need to hard code some column values as empty spaces in my program. That empty spaces might be 40 length long.. i know there is one to do it.. let's say if i need to print out a column with 3 spaces as empty ..

select '   ' as col from dual


I am wondering .. is there any alternate way to do this .. because some fields are longer 40 length long to print out as empty...
fill blank spaces [message #316326 is a reply to message #316324] Thu, 24 April 2008 11:27 Go to previous messageGo to next message
shoaib123
Messages: 118
Registered: December 2007
Location: Chicago
Senior Member

I need to fill up some column values as empty spaces to print out. That empty spaces might be 40 length long.. i know there is one to do it.. let's say if i need to print out a column with 3 spaces as empty ..

select '   ' as col from dual


I am wondering .. is there any alternate way to do this .. because some fields are longer 40 length long to print out as empty...

[Updated on: Thu, 24 April 2008 11:28]

Report message to a moderator

Re: fill blank spaces (merged 3) [message #316327 is a reply to message #316324] Thu, 24 April 2008 11:30 Go to previous messageGo to next message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Have a look at RPAD/LPAD functions.

Regards
Michel
Re: fill blank spaces (merged 3) [message #316331 is a reply to message #316327] Thu, 24 April 2008 11:34 Go to previous messageGo to next message
shoaib123
Messages: 118
Registered: December 2007
Location: Chicago
Senior Member

Appreciate your valuable time.. that help open the window in my brain.
Re: fill blank spaces (merged 3) [message #316335 is a reply to message #316331] Thu, 24 April 2008 12:05 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
huh?

how does this differ from this?
Re: pad/fill blank spaces (merged 4 topics) [message #316426 is a reply to message #316054] Fri, 25 April 2008 02:04 Go to previous messageGo to next message
deepakkrjain
Messages: 4
Registered: April 2007
Location: Delhi
Junior Member

hi all,


this is very eassy to (insert or update) Blank space in null value Column. Used the Chr function. Blank Space Ascii Value is 32.

Syntax: chr(asciicode)

example:

update emp set ename=chr(32) where empno='7844';

1 row updated.



Regards,

[Updated on: Fri, 25 April 2008 02:05]

Report message to a moderator

Re: pad/fill blank spaces (merged 4 topics) [message #316428 is a reply to message #316426] Fri, 25 April 2008 02:07 Go to previous messageGo to next message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Why not just ' '???
What is the need of chr(32)?

Regards
Michel
Re: pad/fill blank spaces (merged 4 topics) [message #316457 is a reply to message #316426] Fri, 25 April 2008 03:15 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
deepakkrjain wrote on Fri, 25 April 2008 09:04
hi all,


this is very eassy to (insert or update) Blank space in null value Column. Used the Chr function. Blank Space Ascii Value is 32.

This has nothing to do with the original question.
Previous Topic: Outer join with variable
Next Topic: How to return row list? (merged)
Goto Forum:
  


Current Time: Tue Dec 06 11:54:04 CST 2016

Total time taken to generate the page: 0.05742 seconds