How can I validate the data in the control file?

Consider that the SQLLoader reads the data entry of the path file and loads the data in the base tables up on top of the description specified in the control file.
First, the form is created:

create table sql_loader_1 (load_time date, digital Champ_1, Champ_2 varchar2 (10))
Example of control file:
load_1.CTL

load data
INFILE "load_1.dat", "str"\r\n"
insert into table sql_loader_1
(
load_time sysdate,
Champ_2 position (01:10).
Champ_1 position(11:20)
)
Note that positions 11 to 20 are loaded in positions 1 to 10 in Champ_2 and Champ_1. The load_time field is filled with time current (sysdate) load.

Here is the data. The name of the file (load_1.dat) had been specified with the statement for infile in the control file.

load_1.dat

0123456789abcdefghij
**********##########
foo bar
This is a very long line
and the next one is
short

declared the Champ_1 as a numeric data type, but the input data file contains the data "Sue"(position 11:20) so the sql loader adds not the record to the database instead the record is written in the bad file. But I want to validate the data of the "(position 11:20) is digital or not." How can I post this in the control file itself? If it is not possible, how can I validate it in the database? give me a sample code to explain this

Here are two ideas.

Idea 1: This control file will check to see if the data to be loaded in Champ_1 contains a number (including the negative and decimal).

load data
infile 'load_1.dat' "str '\r\n'"
insert into table sql_loader_1
(
load_time sysdate,
field_2 position( 1:10),
field_1 position(11:20) "decode(trim(translate(:field_1,'-0123456789.',' ')),null,:field_1,-999)"
) 

If Champ_1 is a number or null, it is passed through, as is. If there is no numeric characters (in addition to '-'and'.') a distinct value-999 will be inserted for you allow to load the rest of the columns and easy to see the lines had data that cannot be loaded in Champ_1. This idea has its flaws (a string like "... ("will always drain the .bad file)

Idea 2: Load the data into a staging table first (or define an external table) where all columns are VARCHAR2. Then use SQL or PL/SQL to validate data in the staging table in your process to move the data into the table with the actual data types.

Tags: Database

Similar Questions

Maybe you are looking for

  • How to upgrade my 256 MB RAM on the Satellite 2450-201?

    How to upgrade my 256 MB RAM on my Toshiba Satellite 2450 201? Where is the RAM located on it?

  • Avoid the button clicks duplicated in the structure of the event

    Hello I have an apparently easy problem that I can't solve. I enclose a VI that illustrates my problem. My problem is this: when an event runs, the OK button is disabled, but if the user clicked the event is pending, and when the process is finished,

  • What happens when ClearTask is never called?

    I use a NOR-6259 with the C API of Linux. What happens when a task program is interrupted and the ClearTask function is never called? Is it possible to query the driver for all running tasks, or better yet, is it possible I can assure that the device

  • Bright screen.

    When connecting line power screen bright decreeses, when I disconnect light increases.  (Bright increases with the power of the battery).  How can I adapt this function?.  Thank you very much.

  • How to reinstall xp home edition? It came with no disk__ restart

    It is bogged down and I want to restore the computer to its factory settings and to clean the disc for my husband to use.  I've defragged and clean the disc until I'm blue in the face and it has not solved the problem.