SQL Loader Control File WHEN Clause Example

SQL Loader Control File WHEN Clause Example

  • SQL
  • 1 min read

In SQL Loader Control File, you can use WHEN clause to tell SQL Loader to load the data only when the condition is true. Also, you can use the WHEN clause to load data into multiple tables. Below is an example.

SQL Loader Control File WHEN Clause Example

LOAD DATA
APPEND
INTO TABLE JOB_HISTORY_10
when DEPARTMENT_ID = '10'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
EMPLOYEE_ID,
START_DATE,
END_DATE,
JOB_ID, 
DEPARTMENT_ID
)
INTO TABLE JOB_HISTORY_20
when DEPARTMENT_ID = '20'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
EMPLOYEE_ID,
START_DATE,
END_DATE,
JOB_ID, 
DEPARTMENT_ID
)

See also:

This Post Has 2 Comments

  1. naresh

    i have a bulk data now have to insert only 10000 records into table through sql loader how can i mention that condition in control file, please help me

  2. Mason

    Why can't we use >= operator in WHEN clause ? What is the workaround to use greater than and equal to?

Comments are closed.