Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> SQL*Loader : Changing values with DECODE

SQL*Loader : Changing values with DECODE

From: MAK <maks70_at_attbi.com>
Date: 24 Oct 2002 18:02:06 -0700
Message-ID: <2d987890.0210241702.52fecc46@posting.google.com>


Folks,

I am trying to load the data using Fixed Format datafile. and changing the value for different columns based on other columns. Here is the control file ,datafile and table structure/data I have used.

SQL>!cat p.ctl

LOAD DATA
INFILE 'p.dat'
REPLACE
PRESERVE BLANKS
INTO TABLE d_test
( id position(1:4) char,
  batch_number position(5:10) char
"DECODE(:id,'AAAA',:batch_number,'CCCC',:batch_number,NULL)",   c_date position(11:16) date "YYMMDD" "DECODE(:batch_number, ' ', NULL, NULL, NULL, :c_date)"
)

SQL>desc d_test

 Name                                      Null?    Type
 ----------------------------------------- --------
----------------------------
 ID                                                 CHAR(4)
 BATCH_NUMBER                                       CHAR(6)
 C_DATE                                             DATE

SQL>!cat p.dat

AAAAXXXXXX021022
BBBB 021023
CCCCYYYYYY021024
DDDDZZZZZZ021023 SQL> select id, nvl(batch_number,'NULL') batch_num, decode(c_date, NULL,'NULL',c_date) CDATE

   from d_test;

ID BATCH_ CDATE
---- ------ -----------
AAAA XXXXXX 22-OCT-2002
BBBB NULL NULL
CCCC YYYYYY 24-OCT-2002
DDDD NULL 23-OCT-2002 Here , I am changing the value of batch_number based value of "ID" column and changing c_date based on batch number. As per the expression , I have in the control file, value for the C_DATE for id DDDD should have been "021023" rather than NULL. I observerd that for value of :batch_number in the decode expression for c_date column , it still picking up the Origional value of 'ZZZZZZ' instead of the modified value of NULL.

Do you know why? Shouldn't SQL*loader pickup the modified value rather than the origional value? Is there any workaround?

Thanks in advance for your quick resolution.

Mak Received on Thu Oct 24 2002 - 20:02:06 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US