Home » RDBMS Server » Server Utilities » truncation of preceeding zeros while loading from csv into oracle table in varchar2 kind of field
truncation of preceeding zeros while loading from csv into oracle table in varchar2 kind of field [message #71269] Sun, 06 October 2002 22:37 Go to next message
Ayan
Messages: 11
Registered: February 2002
Junior Member
While i am loading data from csv file to oracle table, it is truncating all the preceeding zeros

eg i have values 0123 or 00123 or 000123 in csv file. It shows all these values properly in csv file but after loading data into oracle it stores all of them as 123. The data type of my field is varchar2.

Thanks in advance
Ayan
Re: truncation of preceeding zeros while loading from csv into oracle table in varchar2 kind of fiel [message #71271 is a reply to message #71269] Mon, 07 October 2002 04:55 Go to previous message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
use LTRIM.
C:mag>sqlldr userid=mag/mag control=emp.ctl

SQL*Loader: Release 8.1.6.0.0 - Production on Mon Oct 7 08:49:20 2002

(c) Copyright 1999 Oracle Corporation.  All rights reserved.

Commit point reached - logical record count 10
<hr>
this is control file
<hr>
C:mag>type emp.ctl
load data
infile 'testz.txt'
replace
into table test_z
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
(
A char "ltrim(:a,'0')"
)
C:mag>type testz.txt
"1234"
"01234"
"001234"
"0001234"
"0000001"
"0000000"
"asdf"
"234"
"234"
"234"
<hr>
SQL> ed
Wrote file afiedt.buf

  1* select rownum,a from test_z
SQL> /

    ROWNUM A
---------- ----------
         1 1234
         2 1234
         3 1234
         4 1234
         5 1
         6
         7 asdf
         8 234
         9 234
        10 234

10 rows selected.
Previous Topic: users in the wrong tablespace
Next Topic: How to specify row terminater in SQLLDR command
Goto Forum:
  


Current Time: Sun Apr 28 22:40:44 CDT 2024