SQL Loader Control File WHEN Clause Example

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:

2 thoughts on “SQL Loader Control File WHEN Clause Example”

  1. 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

    Reply

Leave a Comment