Loading SELECTIVE Data using SQL Loader

     I need to use SQL loader to load data in Oracle.

    Following issues need to be considered during data load:
    1- If primary key clash occurs during load, ignore that record.
    2- In order to load go successful, I *NEED TO MAKE SURE* that
        certain fields are not null. I can not make those columns NOT NULL
        in DB as for some other LOADS/Application they need to be NULL in table definition.
        IF ANY REQUIRED COLUMN is found NULL whole LOAD should rollback.
        So question is how to define certain columns to be REQUIRED in .ctl file and
        how to rollback whole load as soon as a record is encountered having required field with NULL value.
Thanks a lot
Who is Participating?
PAQed with points refunded (200)

Community Support Moderator
1 cane be acheived easily
2 is not possible (to rollback the whole LOAD) using your current approach.

Easiest way here is to handle using a temp table instead of just SQL*Loader.

Load everything into a copy of your target table, then check for
   1. PK existing in target table
   2. Null columns

You can delete these rows, then load everything else into the target table.  Staging tables are frequently used for this type of problem, especially when you are worried that the data may be incomplete or dirty.
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

9i Introduces EXTERNAL TABLES for this exact reason. You are able to load and transform in the same step.

You can define the file as an external table, and then use a plsql cursor to read the table and insert into target table, and ignore on constraint errors, and you can also check for NULL and rollback if neccessary.
oracopAuthor Commented:
morphman: I like this concept of external tables. Would it be possible to provide an example of external table and related Pl/sql code to process dirty data and load good data in target table to accomplish whole thing in one step?




and search for "external table"

tons of thread alongwith examples.
oracopAuthor Commented:
No answer was satisfactory enough and to the point.

Please refund and close the question.


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.