2

My table data has contains new line character it is loading from sql loader ctl file, one column called 'IPADDRESS'is loading with new line character:

My ctl file :

 load data
 INFILE 'abc.txt'
 INTO TABLE TABLENAME
 APPEND
 FIELDS TERMINATED BY '\|'
 (MAKE,
 CUST_ID "UPPER(:CUST_ID)",
 IPADDRESS  "REGEXP_REPLACE(:IPADDRESS, '\\.\\D+', '', 1, 0)"
 )

Data in table storing is Ex:

Make CUST_ID        IPADDRESS 
------------------------------
C   MPG-VG-ALG01    "9.7.69.37
"
C   MPG-VG-ALG03    "9.7.69.39
"

Sample input file data :

C|mpg-vg-alg01.gdl.mex.ibm.com|9.7.69.37 
C|mpg-vg-alg03.gdl.mex.ibm.com|9.7.69.39 
C|mpg-vg-alg04.gdl.mex.ibm.com|9.7.69.23
Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
Chaya
  • 95
  • 3
  • 12

2 Answers2

1

Answer for my question is : column_name "REPLACE(:column_name,CHR(13),'')";

Rohan Büchner
  • 5,333
  • 4
  • 62
  • 106
Chaya
  • 95
  • 3
  • 12
0

Yes, one option would be using REPLACE() function but need to add more;

  • add CHAR(data_length) for string any data type even if it's of type VARCHAR2
  • add CHR(10)(line feed) also along with CHR(13)(carriage return)
  • don't forget to add TRIM() function nested within REPLACE() against extra issues too
  • using the third argument is redundant

such as

column_name CHAR(4000) "REPLACE(TRIM(:column_name),CHR(13)||CHR(10))"'

moreover

column_name CHAR(4000) "TRANSLATE(TRIM(:column_name),CHR(13)||CHR(10),' ')"' 

might be used as an alternative.

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55