Solved

Loading SELECTIVE Data using SQL Loader

Posted on 2004-08-23
8
633 Views
Last Modified: 2012-06-27
Hello,
     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
0
Comment
Question by:oracop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 13

Expert Comment

by:riazpk
ID: 11872990
1 cane be acheived easily
2 is not possible (to rollback the whole LOAD) using your current approach.

0
 
LVL 7

Expert Comment

by:bvanderveen
ID: 11873378
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.
0
 
LVL 6

Expert Comment

by:morphman
ID: 11875650
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.
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 1

Author Comment

by:oracop
ID: 11943289
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?

Thanks.

0
 
LVL 13

Expert Comment

by:riazpk
ID: 12062154
goto

http://asktom.oracle.com/

and search for "external table"

tons of thread alongwith examples.
0
 
LVL 1

Author Comment

by:oracop
ID: 12589979
No answer was satisfactory enough and to the point.

Please refund and close the question.

Regards.

0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12591517
PAQed with points refunded (200)

modulo
Community Support Moderator
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question