You are on page 1of 63

Oracles SQL*LOADER and Oracles CUSTOMER INTERFACE for DUMMIES

2002 George R Lewycky keywords: oracle, financials, receivables, customer interface, sql*loader, sqlldr, customer data Email: grlewycky@yahoo.com www : http://georgenet.net/oracle

Introduction and Overview


This document will illustrate step by step how to use both the SQL*Loader and Interface data to load customer data for Receivables and other financial products which use Customers. With Oracles poor documentation and tech support and how they force you into using their consultants projects on a tight budget such a basic task can become an expensive time consuming task. I suffered for months trying to load my legacy customer data into Oracle Financials AR and after all the research and suggestions I stuck with using SQL*Loader to load the data into the Oracle tables. Only to learn later on that Oracle requires other fields, values, settings in order for the interface to port the data from the interface table into the real table(s) which are used by Oracles Accounts Receivable. Oracles Customer Interface imports and validates current and/or historical customer information from other systems into Receivables. Once customer information is imported into the system, you can use Customer Interface menu option to import additional data for that customer, such as additional contacts or addresses, and to update existing information. You can also manually update and add new information using the Customer windows. The RA_CUSTOMERS_INTERFACE_ALL table is one of the Customer Interface tables that Oracle Receivables uses to import customer, address, profiles, and site information. Receivables uses this customer information to create records in the RA_CUSTOMERS, RA_ADDRESSES_ALL, RA_CUSTOMER_RELATIONSHIPS_ALL, and RA_SITE_USES_ALL tables. The interface then deletes all records from the table(s) after all of your customer data is successfully imported.

Customer Interface also ensures that records marked for insertions are unique and that the updates exist. The same applies to the updates which must pre-exist.

Table of Contents Introduction and Overview What is needed, Preliminary Set Up and Special SQL functions
Postal Code, Address Validation Automatic Customer and Site Numbering Default Profile Class & Profile Class Amounts How to acquire the valid values for Country Codes Quickcodes: Customer Category, Class, Type, Site Use Code Creating a duplicate TABLE of an existing Table Copying the data from one TABLE to another DELETE ALL ROWS (RECORDS) FROM THE TABLE

How to execute SQL*Loader Errors and tips


SQL*Loader-625: Multibyte character error in control file.

Truncating trailing spaces from the Name Validating record inserted using SQL*Plus Customer Interface tables and their destination table(s)

Creating Data and Control files for SQL*LOADER Other Tips and Procedures Useful Excel macro to create custom delimiter Creating a copy of an existing table to test with Comma Delimited a SQL statement to extract data

Data tips Cleaning up your customer file (removing old, redundant data) Transform all data into uppercase Remove special characters such as and , else extracts, etc. Will become troublesome

Customer Interface What it does Limitations Reporting Error Handling Setup values

Creating a duplicate TABLE of an existing Table Copying the data from one TABLE to another DELETE ALL ROWS (RECORDS) FROM THE TABLE

SQL> select territory_code||','||nls_territory from fnd_territories 2 order by nls_territory; TERRITORY_CODE||','||NLS_TERRITOR --------------------------------DZ,ALGERIA US,AMERICA AU,AUSTRALIA AT,AUSTRIA BH,BAHRAIN BD,BANGLADESH BE,BELGIUM BR,BRAZIL BG,BULGARIA CA,CANADA CN,CHINA RU,CIS HR,CROATIA CY,CYPRUS CZ,CZECH REPUBLIC

WHAT IS NEEDED and SETTING UP

The following is needed on the PC you are working on: 1. 2. 3. 4. SQL*PLUS SQLLDR.EXE (DOS program on the Server machine)

.ctl

file containing the SQL*LOADER code files containing data which matches the fields in SQL*Loader

Try to use NOTEPAD or WORKPAD as your editor for these files. NOTE: keep the sqlldr.exe or sqlload.exe (dos program) and the data and control (.ctl) files all in the same directory to simplify locating and updating files and reading errors, etc. Copy the dos program from the server box.

SETUP

SYSTEM

SYSTEM OPTIONS

TAX

1. Postal Code range from 00000 99999-9999 or from 00000 ZZZZZ-ZZZZ 2.Address Validation set to:

(if international)

NO VALIDATION

If you dont turn off address validation you will be compounded with these messages in the error report for each customer record. Oracle should just default to address validation to OFF.
address reference has 2 different countries address reference has 2 different addr1 values address reference has 2 different cities address reference has 2 different postal codes address reference has 2 different states address reference has 2 identical site use codes address reference has 2 different customers

SETUP 1. 2.

SYSTEM

SYSTEM OPTIONS

TRANS AND CUSTOMER

CHECK the box AUTOMATIC CUSTOMER NUMBERING CHECK the box AUTO SITE NUMBERING

CUSTOMERS

PROFILE CLASSES

Using the Profile Class DEFAULT as shown below populate the Following fields with the values shown: Payment Terms Days in Period 30 Net 30

NOTE: the box at the top right identifies DEFAULT as the profile to be used for Interface process

10

Now click on the Profile Class Amounts tab and in the first empty box under the Currency heading choose your desired currency from the pop up list.

11

How to acquire the valid values for Country Codes


LOAD DATA INFILE 'cust_jan13b.txt' replace INTO TABLE RA_CUSTOMERS_INTERFACE_ALL FIELDS TERMINATED BY '","' ( AGENCY_SKIP FILLER, CUST_SKIP FILLER, ORIG_SYSTEM_CUSTOMER_REF,CUSTOMER_NAME,ADDRESS1, ADDRESS2,CITY,STATE, POSTAL_CODE,COUNTRY,INSERT_UPDATE_FLAG, LAST_UPDATED_BY, LAST_UPDATE_DATE, CREATED_BY,CREATION_DATE,CUSTOMER_CATEGORY_CODE, CUSTOMER_CLASS_CODE, CUSTOMER_STATUS, CUST_SKIP2 FILLER, CUST_NUMBER FILLER, ORIG_SYSTEM_ADDRESS_REF, PRIMARY_SITE_USE_FLAG,SITE_USE_CODE, CUSTOMER_TYPE )

Use this SQL code to derive Oracles country codes you must use in your COUNTRY column shown above.

select territory_code,nls_territory from fnd_territories order by nls_territory


SQL> / TE NLS_TERRITORY -- -----------------------------DZ ALGERIA US AMERICA AU AUSTRALIA AT AUSTRIA BH BAHRAIN BD BANGLADESH BE BELGIUM BR BRAZIL BG BULGARIA CA CANADA CN CHINA

12

Creating a duplicate TABLE of an existing Table


This isnt copying the data or entire database but rather making an exact copy of a tables structure to test a load or copy the data into. create table <newtablename> as select * from <source or original tablename>;

Example:
SQL>

create table temp_cust_int AS Select * from ra_customers_interface;

Copying the data from one TABLE to another


insert into <main table> select * from <temporary table>

DELETE ALL ROWS (RECORDS) FROM THE TABLE


SQL> SQL> delete from temp_cust_int; 221 rows deleted. SQL> commit 2 ; Commit complete.

13

Validate the table by using the DESCription command shown below

14

15

Click the FLASHLIGHT ICON on the upper right corner and then a pop-up box appears. Type the word customer in front of the % to perform a string search for all the customer related variables as shown below.

16

SQL> / CREATED_BY ---------1013 1013 1013 1013 1013 1 1013 1013 1013 1013 1013 CREATED_BY ---------1013 1013 1013 1013 1013 1013 1013 1013 LOOKUP_TYPE -----------------------------CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY LOOKUP_TYPE -----------------------------CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY LOOKUP_CODE -----------------------------BOE CON ED CON ED & LEGAL CON ED-LEGAL CONTRACTOR CUSTOMER DDC DEP-LEGAL DEVELOPER DOT DOT-LEGAL LOOKUP_CODE -----------------------------FARE MEDIA FARE MEDIA-OTHER LEGAL LIB-FARE MEDIA LIRR-FARE MEDIA MNRR-FARE MEDIA MTA METRO-NORTH LOCK. MTA-B&T-OTHER

17

1013 CUSTOMER_CATEGORY 1013 CUSTOMER_CATEGORY 1013 CUSTOMER_CATEGORY CREATED_BY ---------1013 1013 1013 1013 1013 1013 1013 1013 1013 1013 1013 CREATED_BY ---------1013 1013 1013 1013 1013 1 1013 1 1 1 1 1 1 1 CREATED_BY ---------1 1 1 1 1 1 1 1 1 1 1 1 1 LOOKUP_TYPE -----------------------------CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY LOOKUP_TYPE -----------------------------CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_CATEGORY CUSTOMER_OR_VENDOR CUSTOMER_OR_VENDOR CUSTOMER_OR_VENDOR CUSTOMER_PROSPECT_CODE CUSTOMER_PROSPECT_CODE CUSTOMER_PROSPECT_CODE CUSTOMER_RANK LOOKUP_TYPE -----------------------------CUSTOMER_RANK CUSTOMER_RANK CUSTOMER_RANK CUSTOMER_RANK CUSTOMER_STATUS CUSTOMER_STATUS CUSTOMER_STATUS CUSTOMER_STATUS CUSTOMER_STATUS CUSTOMER_TYPE CUSTOMER_TYPE CUSTOMER_TYPE CUSTOMER_TYPE

MTA-HDQ-LOCK MTA-HDQ-OTHER MTA-HDQ-RENT & CONCESS LOOKUP_CODE -----------------------------MTA-LIB-LOCK. MTA-LIB-OTHER MTA-LIRR-FARE MEDIA MTA-LIRR-LOCK MTA-LIRR-OTHER NYC DDC NYC DEP NYC DEP-LEGAL NYC DOT NYS-DOT OTHER LOOKUP_CODE -----------------------------OTHER-CON EDISON LEGAL OTHER-LEGAL PARATRANSIT PARKS POLICE PROSPECT SCRAP SALES BOTH CUSTOMER VENDOR CUSTOMER NEITHER PROSPECT 1 LOOKUP_CODE -----------------------------2 3 4 5 A I X A I I R SPONSOR STUDENT

109 rows selected. select lookup_type,lookup_code,end_date_active from fnd_lookup_values_vl where (lookup_type between 'CUSTOMER_' and 'CUSTOMER_X') order by lookup_type, end_date_active

18

SQL> ED Wrote file afiedt.buf select created_by,lookup_type,lookup_code from fnd_lookup_values_vl where lookup_type between 'CUSTOMER' and 'CUSTOMER_' SQL> / CREATED_BY LOOKUP_TYPE LOOKUP_CODE ---------- ------------------------------ ----------------------------1013 CUSTOMER CLASS MTA 1013 CUSTOMER CLASS NYC 1013 CUSTOMER CLASS OTHER 1 CUSTOMER CLASS PUBLIC SECTOR COMPANIES

19

LOOKUP_TYPE LOOKUP_CODE ------------------------------ --------------------------SITE_USE_CODE ACK SITE_USE_CODE BILL_TO SITE_USE_CODE BOL SITE_USE_CODE CM SITE_USE_CODE DELIVER_TO SITE_USE_CODE DRAWEE SITE_USE_CODE DUN SITE_USE_CODE INV SITE_USE_CODE LEGAL SITE_USE_CODE MARKET SITE_USE_CODE SHIP_TO LOOKUP_TYPE LOOKUP_CODE ------------------------------ --------------------------SITE_USE_CODE SOLD_TO SITE_USE_CODE STMTS 13 rows selected. SQL> ED Wrote file afiedt.buf 1 select lookup_type,lookup_code from ar_lookups 2* where lookup_type='SITE_USE_CODE' SQL>

20

If you are loading Contact information (phone number and contact person) via the Customer Interface you will need to ADD TELEPHONE_TYPE to AR_LOOKUPS and add codes such as VOICE and FAX which correspond to the required data in the

RA_CONTACT_PHONES_INT_ALL table as shown below in the sample record and sqlldr code

"1","2377","12377","I","CORNELIUS","SIGETY","212","410-8789","27-Jun-03","-1","27-Jun03","-1","CUST","5000","CUST5000","PHONE","PHONE5000","CONT","CONT5000","VOICE
LOAD DATA INFILE 'phone0603.txt' insert INTO TABLE RA_CONTACT_PHONES_INT_ALL FIELDS TERMINATED BY '","' (AGENCY_SKIP FILLER, CUST_SKIP FILLER, ORIG_SYSTEM_CUSTOMER_REF, INSERT_UPDATE_FLAG, CONTACT_FIRST_NAME, CONTACT_LAST_NAME, TELEPHONE_AREA_CODE, TELEPHONE, LAST_UPDATE_DATE, LAST_UPDATED_BY, CREATION_DATE, CREATED_BY, CUST_SKIP1 FILLER, CUST_SKIP2 FILLER, ORIG_SYSTEM_ADDRESS_REF, CUST_SKIP3 FILLER, ORIG_SYSTEM_TELEPHONE_REF, TELEPHONE_TYPE)

21

How to execute SQL*LOADER Run your MS-DOS prompt using the Command Prompt as shown below: You cannot run this DOS program through the START RUN method!!!!!

22

Create a single directory, which contains the following: 1. sqlldr.exe you might need to COPY it from the SERVER box NOTE: You need SQL*PLUS installed and configured on your machine or simply Run from the server box 2. all your data files delimited and formatted for SQL*LOADER filename must match the filenames listed in the .CTL code run below Try to create a delimeter such as , Example. First Name,Last Name,Phone, using a comma might not be unique or sufficient for your data. Ive seen some people using ] also 3. all your SQL*LOADER code to load the data files into the interface tables NOTE: all code must end in .CTL 4. SQL*Plus

23

24

Beware of this Error


SQL*Loader-625: Multibyte character error in control file
SQL*Loader: Release 8.1.7.0.0 - Production on Thu May 2 10:07:31 2002 (c) Copyright 2000 Oracle Corporation. All rights reserved. SQL*Loader-625: Multibyte character error in control file.

LOAD DATA
INFILE 'C:\MY SQL\cust_apr30.txt dont ask me why you might need to fully re-type this line,

Re-typing the line seems to fix the problem and load data

25

Enter SQL*PLUS and validate the record count and perform a commit transaction:

The following is needed on the PC you are working on: 5. 6. SQL*PLUS SQLLDR.EXE (DOS program on the Server machine)

Click on the ICON to start SQL PLUS or run through your START menu

Shortcut to Sqlplusw.lnk

In this example enter the following in lowercase: Username Password Host string apps apps vis Vision db or the name of your instance

NOTE: this matches the sqlldr screen print shown below: apps/apps@vis is all one word!!!!

sqlldr apps/apps@vis control=loadint6

26

after the sql loader is finished, start sql*plus and then enter (this is so that the Transaction is finalized) then validate the record count as shown below: the commands you enter are in BOLD
Oracle8i Enterprise Edition Release 8.1.7.1.1 - Production With the Partitioning option JServer Release 8.1.7.1.1 - Production SQL> commit; Commit complete.

commit;

as shown below;

SQL> select count(*) from ra_customers_interface_all; COUNT(*) ---------1 1* select count(*) from RA_CUSTOMER_PROFILES_INTERFACE SQL> / COUNT(*) ---------2 SQL>

27

Truncating trailing spaces from Customer Name If your upload file has fixed length fields and particularly the NAME field has trailing spaces you will need to REMOVE these trailing spaces BEFORE you run the interface otherwise searching customers will encounter problems. Example: 1. 2. ABC Co is not the same as ABC Co Log into SQL*PLUS run the following SQL code

update ra_customers_interface_all set customer_name=rtrim(customer_name);


and then

COMMIT;
NOTE: If you have to do this after the Customer Interface took place use this SQL code

update hz_parties set party_name=rtrim(party_name);


and then

COMMIT;
Example of fixed Length DATA:
9306","BILL CLINTON ","106 9307","NY CITY TRANSIT ","107 9308","LARRY ELLISONS YACHT ","108 9309","MAD SCIENTIST YADA 9309","109 CRAZY CRAZY CRAZY CRAZY AVE AVE AVE AVE "," "," "," "," "," "," "," ","

NOTE: THESE FIXED FILES ARE MUCH EASIER TO CREATE and READ

Example of variable Length DATA:


9306","BILL CLINTON","106 CRAZY AVE",""," 9307","NY CITY TRANSIT","107 CRAZY AVE",""," 9308","LARRY ELLISONS YACHT","108 CRAZY AVE",""," 9309","MAD SCIENTIST YADA 9309","109 CRAZY AVE",""," ALSO NOTE REGARDLESS OF THE FORMAT THE

DELIMITER must be consistent

TEXT WRITE PROGRAM (excel macro) http://tushar-mehta.com/excel/software/text_write_program/index.html has a real useful Macro Text Write Program to delimit , for a text file to be loaded into oracle using SQL, etc Excel will only do commas !!! 28

Truncating spaces and lines on your data file

9306","BILL CLINTON ","106 9307","NY CITY TRANSIT ","107 9308","LARRY ELLISONS YACHT ","108 9309","MAD SCIENTIST YADA 9309","109 blank line blank line

CRAZY CRAZY CRAZY CRAZY

AVE AVE AVE AVE

"," "," "," ","

"," "," "," ","

end of file

The flat ASCII text file containing your data should not: Contain extra spaces at then end of any line Contain blank lines before the EOF (end of file) is reached, otherwise record counts will be misleading along with error messages.

29

Customer Interface Validation Rules The Customer Interface program validates the data you load in the Customer Interface tables by ensuring that the columns in the interface tables reference the appropriate values and columns in the rest of the system. The interface supports the same data relationship for customer information as the customer window. If you are trying to perform updates, Customer Interface ensures that the record to be updated either already exists within the system or is in the interface table in the insert mode. Additionally, Customer Interface ensures that certain column values are consistent with each other. For example, if a profile class is not assigned to a customer, the interface program ensures that interest charge, collector, discount terms, and other profile class information is defined in the appropriate columns. Customer Interface also ensures that records marked for insertion are unique This process is a cumbersome trial and error process. With misleading and convoluted error messages.

RA_CUSTOMERS_INTERFACE Requirements
To import a customer, address, or business purpose, populate the following mandatory columns of RA_CUSTOMERS_INTERFACE:
o o o o o o o o o

ORIG_SYSTEM_CUSTOMER_REF INSERT_UPDATE_FLAG CUSTOMER_NAME CUSTOMER_NUMBER (if you are not using Automatic Customer Numbering) CUSTOMER_STATUS LAST_UPDATED_BY LAST_UPDATE_DATE CREATED_BY 7CREATION_DATE

If you are importing an address and a business purpose, you must also populate the following tables:
o o o o o

PRIMARY_SITE_USE_FLAG (If you are inserting an address) LOCATION (If you are not using Automatic Site Numbering) SITE_USE_CODE (If you are inserting an address) ADDRESS1 ORIG_SYSTEM_ADDRESS_REF 30

Customer Interface Transfer Report


A/R generates the Customer Interface Transfer report each time you run Customer Interface. This report lists the number of records imported into each table and specific error messages describing any problems. If a record in the interface tables has several problems, the Customer Interface Transfer report displays multiple error messages to help you fix all the problems in one step. You can then interface the records successfully the next time you run the Customer Interface program. You may need to make changes in either your feeder program or the system to resolve the errors. The Customer Interface Transfer Report has 3 main sections:
o o o

Header Section Summary of Transfer Section Exception Records Section

The header section displays the date and the time that Customer Interface began processing your transactions. The date is displayed in the format DD-MON-YY, while the time is displayed in the 24-hour format (so that 2:30 PM displays as 14:30). The header section also displays the concurrent request ID used by the Concurrent Manager and the user ID of the person who submitted the Concurrent Request. The Summary of Transfer section displays a count of the customer information processed for each of the tables updated by the interface program. The Exception Records Section displays detailed error messages for each record in each interface tables not successfully processed. This section also displays the original system reference columns from the interface tables to help you identify and correct exception records.

31

After Successfully running the Customer Interface the data is moved from to/from the tables upon which tables you populate FROM:
RA_CUSTOMERS_ALL

TO:
HZ_PARTIES HZ_PERSON_PROFILES HZ_ORGANIZATIONS_PROFILES HZ_CUSTOMER_ACCOUNTS HZ_PARTY_SITES HZ_LOCATIONS HZ_CUST_ACCT_SITES_ALL HZ_CONTACT_POINTS HZ_CUST_CONTACT_POINTS HZ_CUST_ACCCOUNT_ROLES HZ_ORG_CONTACTS HZ_PARTIES HZ_PARTY_RELATIONSHIPS HZ_ROLE_RESPONSIBILITY HZ_CUST_ACCT_RELATE_ALL HZ_CUST_SITE_USES_ALL HZ_CUSTOMER_PROFILE_CLASSES HZ_CUST_PROF_CLASS_AMOUNTS HZ_CUSTOMER_PROFILES HZ_CUSTOMER_PROFILE_AMOUNTS

RA_ADDRESSES_ALL

RA_PHONES RA_CONTACTS

RA_CONTACT_ROLES RA_CUSTOMER_RELATIONSHIPS_ALL RA_SITE_USES_ALL AR_CUSTOMER_PROFILE_CLASSES AR_CUST_PROF_CLASS_AMOUNTS AR_CUSTOMER_PROFILES AR_CUSTOMER_PROFILE_AMOUNTS

For the interface to work at a bare minimum you need RA_CUSTOMERS_ALL & RA_ADDRESSES_ALL populated with the correct data before running the interface
32

Below is a Cross-Reference table of the current A/R Customer file extract against the Oracle Interface table
Create a cross reference table of Oracles fields versus your fields. Especially note the NOT NULL fields which must be given values even if the field has no use to you.

Field from Legacy A/R


original customer number "I"nsert or "U"pdate tells Oracle if record is to be added or updated Customer Name

Notes

Oracle Interface Field

Description

Length

Null/Not Null

4 digit number

ORIG_SYSTEM_CUSTOMER_REF

VARCHAR2

240

NOT NULL

"I"

INSERT_UPDATE_FLAG CUSTOMER_NAME

VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 VARCHAR2 NUMBER DATE NUMBER DATE

1 360 30 1 25 240 240 240 240 60 60 60 15

NOT NULL NOT NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NOT NULL NOT NULL

Oracle will create To be determined To be determined Address Line 1 Address Line 2 Address Line 3 Address Line 4 City State "USA" 95% data if applicable if applicable

CUSTOMER_NUMBER CUSTOMER_STATUS CUSTOMER_TYPE ADDRESS1 ADDRESS2 ADDRESS3 ADDRESS4 CITY STATE COUNTRY LAST_UPDATED_BY

date entered

LAST_UPDATE_DATE CREATED_BY

15

NOT NULL NOT NULL

date entered

CREATION_DATE

NOTE: Where NOT NULL is given a value must be given for the record

33

Procedure for Porting the Customized Customer spreadsheet into Oracle


Save the Excel spreadsheet as a .CSV file to delimit the file so that Oracles SQL code can segregate each field Download the file to the PC Customized SQL code has been written and tested using Oracles SQL*Loader which has been tested to upload the data to Oracles table: RA_CUSTOMERS_INTERFACE_ALL In a DOS Window run the dos program SQLLDR.EXE
> sqlldr apps/apps@vis loadtbag.ctl all one word!!! < enter a filename containing the code >

Control =

Loadtbag.ctl is shown below: load data infile 'c:\MY SQL\oracust.txt' flat file of the DATA !!!! replace replace or append into table tbagcust Oracle table created above fields terminated by '","' delimiter (AUTH,CUST, NAME, all fields ADDRESS1,ADDRESS2,ADDRESS3,ADDRESS4, CITYCOUNTRY,STATE,ZIP,PHONE,CONTACT,DATEADDED )

sample of the data file NOTE: the first field DOESNT have , preceding it, only succeeding it !!!!!! This is due to fields terminated by '","' which is the delimiter separating the fields just like we do for spreadsheets
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 ********************************* Top of Data ********************************** 1","0066","ABC BUS MANUFACTURING ","1506 30TH STREET ","NORTHWEST 1","0068","ABC RAIL PRODUCTS CORP. ","11TH & WASHINGTON STREETS"," 1","0070","ABCO REFRIGERATION SUPPLY","49-70 31ST STREET "," 1","0090","ABEE PRINTING CORP. ","305-1 KNICKERBOCKER AVE. ","

If you use append data must already be on the table Other options were explored for loading this data and SQL*Loader was found to be the most effective for the amount of data being processed.

Useful Excel Macro to delimit , - note Excel alone wont allow such a delimiter

TEXT WRITE PROGRAM (excel macro) http://tushar-mehta.com/excel/software/text_write_program/index.html has a real useful Macro Text Write Program to delimit , for a text file to be loaded into oracle using SQL, etc Excel will only do commas !!! 34

How to execute SQL*LOADER Run your MS-DOS prompt using the Command Prompt as shown below: You cannot run this DOS program through the START RUN method!!!!!

35

Create a single directory, which contains the following: 4. sqlldr.exe you might need to COPY it from the SERVER box NOTE: You need SQL*PLUS installed and configured on your machine or simply Run from the server box 5. all your data files delimited and formatted for SQL*LOADER filename must match the filenames listed in the .CTL code run below Try to create a delimeter such as , Example. First Name,Last Name,Phone, using a comma might not be unique or sufficient for your data. Ive seen some people using ] also 6. all your SQL*LOADER code to load the data files into the interface tables NOTE: all code must end in .CTL 4. SQL*Plus

36

37

38

Before you run the Interface Customer you should run SQL*Plus and count the amount of records in the tables you uploaded the data into. Note after you run a successful Customer Interface Oracle will automatically delete all the records you uploaded.

39

Procedure for invoking the Oracle Interface Processing after the data has been loaded into the RA_CUSTOMER_INTERFACE_ALL table
Within Oracle A/R choose the Interface sub-menu and then choose Customer so that Oracle can insert (or update), process, validate and spread out the data into numerous tables automatically

After selecting Customer another screen will then appear as shown on the next page

40

This screen now appears to port the file into Oracles interface table

41

The following is needed on the PC you are working on: SQL*PLUS SQLLDR.EXE (DOS program on the Server machine)

Click on the ICON to start SQL PLUS

Shortcut to Sqlplusw.lnk

In this example enter the following in lowercase: Username Password Host string apps apps vis Vision db

NOTE: this matches the sqlldr screen print shown below: apps/apps@vis is all one word!!!!

sqlldr apps/apps@vis control=loadint6 log=yadaint

42

Validate the table by using the DESCription command shown below

43

44

Creating a duplicate TABLE of an existing Table


This isnt copying the data or entire database but rather making an exact copy of a tables structure to test a load or copy the data into. create table <newtablename> as select * from <source or original tablename>;

Example:
SQL>

create table temp_cust_int AS Select * from ra_customers_interface;

Copying the data from one TABLE to another


insert into <main table> select * from <temporary table>

DELETE ALL ROWS (RECORDS) FROM THE TABLE


SQL> SQL> delete from temp_cust_int; 221 rows deleted. SQL> commit 2 ; Commit complete.

45

Comma Delimiting a SQL statement output for a spreadsheet, etc


SQL> select territory_code||','||nls_territory from fnd_territories 2 order by nls_territory;
TERRITORY_CODE||','||NLS_TERRIT --------------------------------DZ,ALGERIA US,AMERICA AU,AUSTRALIA AT,AUSTRIA BH,BAHRAIN BD,BANGLADESH BE,BELGIUM BR,BRAZIL BG,BULGARIA CA,CANADA CN,CHINA RU,CIS HR,CROATIA CY,CYPRUS CZ,CZECH REPUBLIC

46

Validate the table by using the DESCription command shown below

47

How to acquire the valid values for Country Codes


LOAD DATA INFILE 'cust_jan13b.txt' replace INTO TABLE RA_CUSTOMERS_INTERFACE_ALL FIELDS TERMINATED BY '","' ( AGENCY_SKIP FILLER, CUST_SKIP FILLER, ORIG_SYSTEM_CUSTOMER_REF,CUSTOMER_NAME,ADDRESS1, ADDRESS2,CITY,STATE, POSTAL_CODE,COUNTRY,INSERT_UPDATE_FLAG, LAST_UPDATED_BY, LAST_UPDATE_DATE, CREATED_BY,CREATION_DATE,CUSTOMER_CATEGORY_CODE, CUSTOMER_CLASS_CODE, CUSTOMER_STATUS, CUST_SKIP2 FILLER, CUST_NUMBER FILLER, ORIG_SYSTEM_ADDRESS_REF, PRIMARY_SITE_USE_FLAG,SITE_USE_CODE, CUSTOMER_TYPE )

Use this SQL code: select territory_code,nls_territory from fnd_territories order by nls_territory
SQL> / TE NLS_TERRITORY -- -----------------------------DZ ALGERIA US AMERICA AU AUSTRALIA AT AUSTRIA BH BAHRAIN BD BANGLADESH BE BELGIUM BR BRAZIL BG BULGARIA CA CANADA CN CHINA

48

How to STRING 2 or more columns together. You might have to merge two fields together as shown below. Columns S and T form column U. This is needed for Oracles use for the ORIG_SYSTEM_ADDRESS_REF field.

Note the formula

=S1&&T1

For more info use EXCELs HELP look for: About joining text and values in multiple cells

49

HOW TO USE SQL*Loader


sqlldr.exe dos program to load the data into oracle tables .log = results of load .txt = data .ctl = sql loader code to load the columns into tables

KEEP ALL THESE FILES AND THE PROGRAM ALL IN THE SAME DIRECTORY

MAKE A NEW VERSION OF THE .CTL WHEN NECESSARY ALSO

50

51

Code for CUSTOMER INTERFACE

loadracust2.ctl
LOAD DATA INFILE 'abagcus2.txt' DATA FILE!!!!!!!!!!!!!!!!!!!!!!!!! replace INTO TABLE RA_CUSTOMERS_INTERFACE_ALL ****** see below FIELDS TERMINATED BY '","' TRAILING NULLCOLS ( ORIG_SYSTEM_CUSTOMER_REF,CUSTOMER_NAME,ADDRESS1, ADDRESS2,ADDRESS3,ADDRESS4,CITY,STATE, POSTAL_CODE,COUNTRY,INSERT_UPDATE_FLAG, LAST_UPDATED_BY, LAST_UPDATE_DATE, CREATED_BY,CREATION_DATE,CUSTOMER_CATEGORY_CODE, CUSTOMER_STATUS,ORIG_SYSTEM_ADDRESS_REF, PRIMARY_SITE_USE_FLAG,SITE_USE_CODE, CUSTOMER_TYPE )

loadraprof3.ctl
LOAD DATA INFILE 'abagprof2.txt' data file replace INTO TABLE RA_CUSTOMER_PROFILES_INT_ALL FIELDS TERMINATED BY '","' TRAILING NULLCOLS ( ORIG_SYSTEM_CUSTOMER_REF, INSERT_UPDATE_FLAG, CREDIT_HOLD, LAST_UPDATED_BY, LAST_UPDATE_DATE, CREATED_BY,CREATION_DATE, ORIG_SYSTEM_ADDRESS_REF, CUSTOMER_PROFILE_CLASS_NAME )

replace INTO TABLE RA_CUSTOMERS_INTERFACE_ALL


on this line other than REPLACE, you also have INSERT if the table hasnt been used before

52

loadrainv.ctl LOAD DATA INFILE 'annainv0812.txt' replace INTO TABLE RA_INTERFACE_LINES_ALL FIELDS TERMINATED BY '","' TRAILING NULLCOLS (ORIG_SYSTEM_BILL_CUSTOMER_REF, AMOUNT,BATCH_SOURCE_NAME,SET_OF_BOOKS_ID,LINE_TYPE, DESCRIPTION,CURRENCY_CODE,CONVERSION_TYPE, INTERFACE_LINE_ID,INTERFACE_LINE_CONTEXT )

loadraerr.ctl LOAD DATA INFILE 'annaerror.txt' replace INTO TABLE RA_INTERFACE_ERRORS_ALL FIELDS TERMINATED BY '","' TRAILING NULLCOLS (INTERFACE_LINE_ID )

loadradist.ctl LOAD DATA INFILE 'annadist.txt' replace INTO TABLE RA_INTERFACE_DISTRIBUTIONS_ALL FIELDS TERMINATED BY '","' TRAILING NULLCOLS (INTERFACE_LINE_ID,INTERFACE_LINE_CONTEXT,ACCOUNT_CLASS )

53

SAMPLE DATA FORMAT:

12000","I","N","-1","15-AUG-02","-1","15-AUG-02","","DEFAULT"," 12000","I","N","-1","15-AUG-02","-1","15-AUG-02","CUST2001","DEFAULT","

note the following: the end of each RECORD must end in , end of each column (field) is separated with a , the start of each RECORD is just the data the delimiter specified in the sqlloader code is first used between the first and 2nd field (column)
Creating Comma Delimited File If you are on a legacy mainframe system I suggest using SYNCSORT/DFSORT to pull desired fields into a fixed flat file. Only problem you might have are extra trailing spaces that can pose a problem with the name field, etc. o Also you might be able to generate unique sequence numbers for use by Oracle Use Excel, Lotus, Quattro to produce a spreadsheet of data with a unique delimiter.

54

How to STRING 2 or more columns together. You might have to merge two fields together as shown below. Columns S and T form column U. This is needed for Oracles use for the ORIG_SYSTEM_ADDRESS_REF field.

Note the formula

=S1&&T1

For more info use EXCELs HELP look for: About joining text and values in multiple cells

55

56

Procedure to LOAD THE DATA !!!!!!!!!!!!


1. 2. Keep the .ctl, .txt (data) and sqllldr.exe all in the same directory CLICK : START then PROGRAMS then COMMAND PROMPT to enter DOS YOU HAVE TO ENTER DOS THIS WAY AND NOT THROUGH THE RUN PROMPT!!!!!!!!!!! Change directory to the directory with the data, .ctl and sqllldr.exe reside

3.

57

IN YOUR DOS WINDOW RUN YOUR SQLLOADER CODE AS SHOWN ABOVE

HERE IS THE SYNTAX

DOS> sqlldr apps/apps@argt CONTROL FILENAME CONTROL FILENAME IS THE CODE CONTAINING THE COLUMNS, TABLENAME BEING LOADED ( .ctl ) EX. Sqlldr apps/apps@argt loadracust2

58

NOW WHAT??????

After it runs ok you will see commit point appearing for breakpoints indicating Records went through YOU SHOULD CHECK THE .log files

Loadracust2.log
SQL*Loader: Release 8.1.7.0.0 - Production on Mon Aug 26 10:23:59 2002 (c) Copyright 2000 Oracle Corporation. Control File: loadracust2.ctl Data File: abagcus2.txt Bad File: abagcus2.bad Discard File: none specified (Allow all discards) Number to load: Number to skip: Errors allowed: Bind array: Continuation: Path used: ALL 0 50 64 rows, maximum of 65536 bytes none specified Conventional All rights reserved.

Table "AR"."RA_CUSTOMERS_INTERFACE_ALL", loaded from every logical record. Insert option in effect for this table: REPLACE TRAILING NULLCOLS option in effect Column Name Position Len Term Encl Datatype ------------------------------ ---------- ----- ---- ---- -------------------ORIG_SYSTEM_CUSTOMER_REF FIRST * CHARACTER Terminator string : '","' CUSTOMER_NAME NEXT * CHARACTER Terminator string : '","' ADDRESS1 NEXT * CHARACTER Terminator string : '","' ADDRESS2 NEXT * CHARACTER Terminator string : '","' ADDRESS3 NEXT * CHARACTER Terminator string : '","' ADDRESS4 NEXT * CHARACTER Terminator string : '","' CITY NEXT * CHARACTER Terminator string : '","' STATE NEXT * CHARACTER Terminator string : '","' POSTAL_CODE NEXT * CHARACTER Terminator string : '","' COUNTRY NEXT * CHARACTER Terminator string : '","' INSERT_UPDATE_FLAG NEXT * CHARACTER Terminator string : '","' LAST_UPDATED_BY NEXT * CHARACTER

59

Terminator string : LAST_UPDATE_DATE Terminator string : CREATED_BY Terminator string : CREATION_DATE Terminator string : CUSTOMER_CATEGORY_CODE Terminator string : CUSTOMER_STATUS Terminator string : ORIG_SYSTEM_ADDRESS_REF Terminator string : PRIMARY_SITE_USE_FLAG Terminator string : SITE_USE_CODE Terminator string : CUSTOMER_TYPE Terminator string :

'","' NEXT '","' NEXT '","' NEXT '","' NEXT '","' NEXT '","' NEXT '","' NEXT '","' NEXT '","' NEXT '","' * CHARACTER * CHARACTER * CHARACTER * CHARACTER * CHARACTER * CHARACTER * CHARACTER * CHARACTER * CHARACTER

Table "AR"."RA_CUSTOMERS_INTERFACE_ALL":

1 Row successfully loaded.


0 Rows not loaded due to data errors. 0 Rows not loaded because all WHEN clauses were failed. 0 Rows not loaded because all fields were null. Space allocated for bind array: Space allocated for memory besides bind array: Total logical records skipped: Total logical records read: 0 1 65016 bytes(12 rows) 0 bytes

Total logical records rejected:


Total logical records discarded:

0
0

Run began on Mon Aug 26 10:23:59 2002 Run ended on Mon Aug 26 10:24:03 2002 Elapsed time was: CPU time was: 00:00:03.62 00:00:00.19

Then you can run your interface, etc. The amount loaded should equal the amount read.

60

INTERFACE ERROR HANDLING


You are running Customer Interface and there is an error message in the INTERFACE_STATUS column, but you don't know what it means.
SQL> select interface_status from

ra_customers_interface_all;

change to appropriate

table INTERFACE_STATUS B0,O3,E2,D1,D2,D3,D4,D5,D6,D7,D0,E1, B0,O3,E2,D1,D2,D3,D4,D5,D6,D7,D0,E1, B9,B0,O3,E2,D1,D2,D3,D4,D5,D6,D7,D0,E1, B0,O3,E2,D1,D2,D3,D4,D5,D6,D7,D0,E1, B9,B0,O3,E2,D1,D2,D3,D4,D5,D6,D7,D0,E1,

NOTE: THIS APPLIES TO ALL INTERFACE TABLES!!!!!!!!!!!!!!! EACH TABLE HAS THIS FIELD

Metalink, and search for Document ID: 1073634.6 Doc ID: Note:1073634.6

Subject: CUSTOMER INTERFACE STATUS ERROR CODES

61

SQL LOADER sample and example

Find the DOS program SQLLDR.EXE you might have to copy it from your server machine and onto your PC where you are loading the data from. Resides in the bin directory. Do a file search in Windows for that exact filename. Enter sqlldr.exe | more to see the commands http://ugweb.cs.ualberta.ca/~c391/manual/chapt5.html VERY GOOD!!!!

http://utenti.lycos.it/yanorel4/1/ch25.htm Que: Using oracle 8Chapter 25 Using SQL*Loader and Export/Import http://www.smckearney.com/oracle/sqlloader.php

Oracle Resources Using SQL-Loader to load data into Oracle


http://kachina.kennesaw.edu/~agalewsk/SQLloader.html
http://technet.oracle.com/doc/server.815/a67792/ch04.htm http://www.doag.org/mirror/frank/faqloadr.htm http://misdev.fnal.gov/oracledoc/v8.1.7/DOC/server.817/a76955/ch03.htm http://gis.stpaul.gov/docs/oracle/server803/A54652_01/ch08.htm http://www.cs.uvm.edu/oracledoc/server.815/a67792/ch03.htm http://people.cs.uchicago.edu/~matei/TA/CS235/or-load.html http://ugweb.cs.ualberta.ca/~c391/labs/Sqlplus_Sqlloader.html http://wpi.wpi.edu/server.815/a67792/ch04.htm http://www.rumken.com/ioug2000/Paper421.htm SQL*Loader and Database Triggers http://ftp.ora.com/orsqlloader/
Using the Oracle Bulk Loader

GOOD EXAMPLE!

CASE STUDIES Replacing 3GL Data Loading with

Oracle SQL*Loader: The Definitive Guide Examples

NOTE: If using Excel save spreadsheet at CSV to create comma delimited file
SQL*LOADER ERROR LISTING: http://storacle.princeton.edu:9001/oracle8-doc/server.805/a58312/newch73.htm http://info-it.umsystem.edu/oradocs/doc/server/doc/MSG73/ch7.htm http://wpi.wpi.edu/server.815/a67792/ch07.htm LOG FILE

62

Written by George R Lewycky 5/14/02 4:43 PM grlewycky@yahoo.com http://georgenet.net/oracle http://groups.yahoo.com/group/OracleSharedInfo/

63

You might also like