Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I use a '>' or '<' in the when clause of a control file?

LOAD DATA
INFILE 'Sample2.dat'
APPEND INTO TABLE EMP_LEAVE
WHEN REQUEST_DATE > SYSDATE  --The problem lies here
FIELDS TERMINATED BY ","
(REQUEST_NO,
EMPNO,
REQUEST_DATE    DATE    "DD-MM-YYYY",
START_DATE  DATE    "DD-MM-YYYY",
END_DATE        DATE    "DD-MM-YYYY",
REASON,
LEAVE_TYPE,
NO_OF_DAYS,
APPROVAL
)

I’m trying to insert only those rows where the REQUEST_DATE is higher than the current date. Any idea how I could do that?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

As far as I can tell, you can’t directly from SQL*Loader.

WHEN clause, which is used to conditionally load records, accepts only "equal" or "not equal" operators, i.e. =, <> or !=, i.e. you can’t use "greater than" > and similar.

For more info, see this:

A field condition is a statement about a field in a logical record
that evaluates as true or false. It is used in the WHEN, NULLIF,
and DEFAULTIF clauses.

(…)

operator: A comparison operator for either equal or not equal.

So, what to do?

  • load data into a temporary table and then extract rows you want
  • instead of SQL*Loader, use external tables feature which lets you write a query against it (i.e. you’re directly accessing the file as if it were an "ordinary" table, so you can use any WHERE clause you want, including where request_date > sysdate)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading