Mapping fields in Oracle SQL Loader

前端 未结 1 519
长发绾君心
长发绾君心 2021-01-25 13:22

When loading an external csv with Oracle SQL Loader is there a way to map the fields directly to each other in the control file?

At the moment I\'m doing a simple loadin

1条回答
  •  孤街浪徒
    2021-01-25 14:08

    You can include any data processing by means of Oracle functions in your control file.
    E.g., this code swaps columns 1 and 2 and additionally converts source_field2 to number, silently replacing wrong values to nulls:

    load data
    append
    into table SCHEMA.TABLE
    fields terminated by ';' optionally enclosed by '"'
    trailing nullcols
    (
      source_field1     BOUNDFILLER,
      source_field2     BOUNDFILLER,
      source_field3     BOUNDFILLER,
      destination_field1 "to_number(regexp_substr(:source_field2, '^[-0-9,]*'),'9999999999D999','NLS_NUMERIC_CHARACTERS='', ''')",
      destination_field2 ":source_field1",
      destination_field3 ":source_field3"
    )
    

    0 讨论(0)
提交回复
热议问题