Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reg : CHR(10) and CHR(13)

915396Jan 9 2013 — edited Jan 9 2013
Hi Experts,

I've a small doubt regarding the CR and LF.

Suppose, i have a comma separated value list say - 'a,b,c,d,e' and want to replace the Commas ',' with Newlines.
Initially I thought replacing always with CHR(13)||CHR(10) will do, but got confused when tried experimenting with the below code -
-- "Output seen in NOTEPAD++"
SQL> select
  2      replace('a,b,c,d,e',',',CHR(10)) x1,
  3      replace('a,b,c,d,e',',',CHR(13)) x2,
  4      replace('a,b,c,d,e',',',CHR(13)||CHR(10)) x3,
  5      replace('a,b,c,d,e',',',CHR(10)||CHR(13)) x4
  6  from
  7  dual;

X1        X2        X3            X4                                                                                                        
--------- --------- ------------- -------------                                                                                             
a         a b
c
d
e a             a                                                                                                         
b                   b             
b                                                                                                        
c                   c             
c                                                                                                        
d                   d             
d                                                                                                        
e                   e              e                                          

-- "But in SQL Plus Editor is seen differently"
-- "Again the output is visually different in Toad"
Database details :
BANNER                                                                                                                                      
----------------------------------------------------------------                                                                            
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi                                                                            
PL/SQL Release 10.2.0.3.0 - Production                                                                                                      
CORE	10.2.0.3.0	Production                                                                                                                  
TNS for Solaris: Version 10.2.0.3.0 - Production                                                                                            
NLSRTL Version 10.2.0.3.0 - Production            
Can anybody please explain me the underlying concept?
Any pointers/clarification is highly appreciated.

Ranit B.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 6 2013
Added on Jan 9 2013
4 comments
10,542 views