Solved

Oracle Sql Loader / PLSQL Data Validation

Posted on 2014-03-26
6
1,516 Views
Last Modified: 2014-03-26
I receive a pipe delimited file that I load using SQL Loader. I have been asked to verify the pipe count in the file as a means to validate that all columns are accounted for.

Example: The file should be
col1|col2|col3|col4|col5

If I get a file like this
col1|col2|col3
it should not accept the file.

The pipe count should be five not two for each row.

My questions is two fold:

1. Will SQL Loader bomb on a file that does not have all of the columns defined, I'm receiving a variable length file.

2. Is there a way to do this with a stored procedure and can you give me ideas? I'm thinking of using UTL_File or should I load file in one big column and count the | in each row. Usually these files are large and I'm not sure about an approach.

Thanks.
0
Comment
Question by:SharonBernal
6 Comments
 
LVL 32

Expert Comment

by:awking00
ID: 39956285
On what kind of file system do these files reside (e.g. Windows, Unix, etc.)?
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 39956310
on a windows server use this scripts
and providing the records are 1 line based

findstr /V /N ".*|.*|.*|.*|.*" c:\data\your_input_file.txt > incorrect_lines.txt

Open in new window


it should give a list of the incorrect lines preceded by a line number
doing a line count on the file gives the count
0
 

Author Comment

by:SharonBernal
ID: 39956317
It's a Unix system.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 39956329
don't have unix but i'm guessing grep can do that
0
 
LVL 35

Accepted Solution

by:
johnsone earned 500 total points
ID: 39956652
What behavior are you looking for?  Should SQL*Loader ignore the records that are missing columns, or should the whole file be ignored?

If you are looking to just ignore the records that are missing columns, then as long as you do not specify TRAILING NULLCOLS in the control file, you should be OK.  See the documentation here -> http://docs.oracle.com/cd/E16655_01/server.121/e17639/ldr_control_file.htm#SUTIL1121

If you want to ignore the whole file, then you be sure that you do not set TRAILING NULLCOLS and make sure that you also set ERRORS=0.  That should cause the load to terminate on the first error.
0
 

Author Closing Comment

by:SharonBernal
ID: 39956743
Or business rule would be to ignore the entire file. This is what I needed to know. Thank you.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
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 Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

756 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