Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2014
    Posts
    44

    Unanswered: Skipping char '-' in ORACLE SQL*LOADER

    Dear folks,

    How do i write in the ctl file to treat char '-' and put 0 value into the database ?
    so far I have this in my script,

    -- THIS IS TO LOAD DATA INTO EMPTY TABLE
    LOAD DATA
    INFILE "C:\FABRIC_ME_BLD.csv"
    BADFILE "FABRIC_ME_BLD.bad"
    DISCARDFILE "FABRIC_ME.dsc"
    INSERT
    INTO TABLE "FABRICATION"
    FIELDS TERMINATED BY ','
    (
    ITEM_ID,
    CUTTING,
    ASSEMBLY ,
    WELDING ,
    DRILLING ,
    FINISHING
    )

    Thanks a bunch

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    show an example of the c:\fabric_me_bld.csv file.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    why not use plain text editor to change the file content before loading it into Oracle DB?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  4. #4
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    Quote Originally Posted by chrishutagalung View Post
    Dear folks,

    How do i write in the ctl file to treat char '-' and put 0 value into the database ?
    so far I have this in my script,
    . . . E t c . . .
    Thanks a bunch
    Like this?:
    Code:
    LOAD DATA
    INFILE "C:\FABRIC_ME_BLD.csv"
    BADFILE "FABRIC_ME_BLD.bad"
    DISCARDFILE "FABRIC_ME.dsc"
    INSERT INTO TABLE "FABRICATION"
    FIELDS TERMINATED BY ','
    (
      ITEM_ID
    , CUTTING     "DECODE(:CUTTING,'-','0',:CUTTING)"
    , ASSEMBLY    "DECODE(:ASSEMBLY ,'-','0',:ASSEMBLY )"
    , WELDING     "DECODE(:WELDING ,'-','0',:WELDING )"
    , DRILLING    "DECODE(:DRILLING ,'-','0',:DRILLING )"
    , FINISHING   "DECODE(:FINISHING,'-','0',:FINISHING)"
    )
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  5. #5
    Join Date
    Mar 2014
    Posts
    44
    Quote Originally Posted by anacedent View Post
    why not use plain text editor to change the file content before loading it into Oracle DB?
    the database contains million datas already put into excel. its gonna be crazy if i use text editor to edit them all

  6. #6
    Join Date
    Mar 2014
    Posts
    44
    Quote Originally Posted by beilstwh View Post
    show an example of the c:\fabric_me_bld.csv file.
    there you go ... thanks for your help
    Attached Files Attached Files

  7. #7
    Join Date
    Mar 2014
    Posts
    44
    Quote Originally Posted by LKBrwn_DBA View Post
    Like this?:
    Code:
    LOAD DATA
    INFILE "C:\FABRIC_ME_BLD.csv"
    BADFILE "FABRIC_ME_BLD.bad"
    DISCARDFILE "FABRIC_ME.dsc"
    INSERT INTO TABLE "FABRICATION"
    FIELDS TERMINATED BY ','
    (
      ITEM_ID
    , CUTTING     "DECODE(:CUTTING,'-','0',:CUTTING)"
    , ASSEMBLY    "DECODE(:ASSEMBLY ,'-','0',:ASSEMBLY )"
    , WELDING     "DECODE(:WELDING ,'-','0',:WELDING )"
    , DRILLING    "DECODE(:DRILLING ,'-','0',:DRILLING )"
    , FINISHING   "DECODE(:FINISHING,'-','0',:FINISHING)"
    )
    thanks, i will try this

  8. #8
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    I do not see any records in the sample data you provided that have single dash "-" in fields two to six, but rather a pattern like this:
    Code:
    . . .
    ME-BD2-C 38,1,1,1,1,1,ME-BD2-C 38
    ME-BD2-C 38-A,0,0,0,0,0,ME-BD2-C 38-A
    ME-BD2-C 39,2,2,2,2,2,ME-BD2-C 39
    . . .
    Provide us with an expected result based on this data or some more significant data sample.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •