You are on page 1of 27

Oracle Tips, Tips, Tricks, Utilities and Resources By George Lewycky Wednesday, February 14, 2007

Two very useful websites & email discussions groups SQL tricks for delimiting data into a spooled file Text Write Excel macro to delimit Excel spreadsheets into ASCII text data with any desired delimiter for SQL*Loader Copying a table Copying a table from another machine Oracles SQL*Loader (a.k.a. Bulk Loader) o Intro, Overview, examples, features o Fixed or Delimited??? o DOS Script to automate the load process (DOS) SQL*Loader web sites and references o DOS & Unix Questions

Here are two very useful and (a word Transit likes to hear) websites/email discussion list (also available in digest form). You can post your question and reply to other members questions and answers. Learn and collect many tips and solutions. Personally I also collect useful postings in a separate Outlook folder You are in direct communication with others in the field that might have had the same problem(s) or experience that you can benefit from rather than METALINK.

HTTP://ORACLE.ITTOOLBOX.COM ITTOOLBOX contains the following ORACLE RELATED discussion lists, along with various languages, operating systems, ERPs, 3rd party products, etc
oracle-apps-l oracle-appserver-l oracle-bi-l oracle-crm-l oracle-db-backup-l oracle-db-installs-l oracle-db-l oracle-db-tuning-l oracle-db-upgrades-l oracle-dev-l oracle-dw-l oracle-forms-l oracle-fusion-wiki-project oracle-jdeveloper-l oracle-sql-l 5,626 3,955 4,178 3,724 4,635 4,787 6,180 5,618 4,614 5,000 3,359 1,136 369 893 1,966

I have been a contributing member since December 2001 and it has benefited our projects tremendously. I learn and shared a lot to/from other programmers and I collect postings for future use and reference!

HTTP://WWW.EXFORSYS.COM/ Exforsys is a community of developers specializing in C, C++, C#, Java, J2EE, .NET, PeopleSoft, SAP, Siebel, Oracle Apps., Data warehousing, Oracle/SQL Server/DB2 and Testing, who have come together to share Source code, Articles, Certification details, Interview questions, Job postings, Trainings and on-line tutorials.

SQL tricks for delimiting data into a spooled file


filename: xxx.sql
set heading off set linesize 100 set pagesize 0 set feedback off spool c:\test.txt select jobno ||'","',nyctpm ||'","', descr || '","' from jobxref; spool off - - - outfile: 95578"," 95579"," 95580"," - - - - - output - - - - - - - - test.txt LIONEL SAINT LOUIS"," CORRECT-FALLING DEBRIS,ICE,WAT"," MIRON KUCHUK "," RECONSTRUCTION OF FLUSHING AVE"," MIRON KUCHUK "," RESURFACING OF MCDONALD AVENUE","

- - - - - OR THIS MUCH SIMPLER METHOD - - - - - - - colsep.sql


SET SERVEROUTPUT ON SET ECHO OFF SET VERIFY OFF SET Heading OFF SET LINESIZE 2000 SET NEWPAGE NONE SET PAGESIZE 100 SET Heading OFF SET COLSEP , <- this saves you the headache of coding each column!!! spool example1.txt select * from jobxref where nyctpm like ('%J.G. SUMMERS%'); spool off
SQL> @colsep 97474,J.G. SUMMERS 97479,J.G. SUMMERS 97417,J.G. SUMMERS 97418,J.G. SUMMERS 97365,J.G. SUMMERS 97265,J.G. SUMMERS 97266,J.G. SUMMERS 7 rows selected. SQL> ,TO REPLACE MATERIAL EQUIPMENT, ,INSTALL NEW DATA CABLING, A NO ,TO REPLACE RADIO FRECUENCY (RF ,TO REPLACE MATERIAL HANDLING E ,REPLACEMENT-MATERIAL HANDLING ,REPLACE MATERIAL HANDLING EQUI ,PUR.3 RETRIEVAL MACHINES-ZEREG

NOTE: if any of the columns have ',' embedded in them like the address you might be in a bind.

So you might need a unique delimiter like '|' or ']'


You must include tick marks with this delimiter!!! See below line: SET COLSEP '|'
92877|S SHECTER 92881|S SHECTER

or SET COLSEP ']'

Then your file will look something like this:


|EMGINEERING & TECHNICAL FIELD |ENGINEERING & TECHNICAL FIELD

NOTE: only drawback can be excess trailing / padded spaces


3

Very useful Excel macro to use with an Excel spreadsheet to delimit your DATA with any Delimiter desired ( , | ] )

http://www.smokeylake.com/excel/text_write_program.htm http://www.smokeylake.com/excel/

Text Write Program


The Text Write Program is a Microsoft Excel workbook with a macro program that writes any sheet of any open workbook to a text file with lots of options. Setup Sheet. Here you specify your options. There is help on the options. A typical setup sheet: File Name to write: Record Delimiter: Code/Character Stop if Record Delimiter found in cell?: Field Delimiter: Code/Character Bracketing Code/Character (text qualifier): Bracket data fields?: Bracket blank fields also?: Skip blank rows?: Write entire sheet?: If no, Expand selection?: If no, write rectangular?: a.txt, or C:\My Documents\a.txt 13,10 Yes , (comma) " (quotation mark) Yes No No Yes No No

Then you switch to the sheet to be written (in any open workbook), and press Ctrl-Shift-W. It writes the file, letting you know its progress. Download Text Write Program The Text Write Program is now at the 1d level. Text Write Program-1d.xls. There are some fixes and some enhancements.

INSTRUCTIONS: (1) In EXCEL open your TEXT WRITE spreadsheet with the macro (2) Enter the filename you want outputted and change delimiter, etc if needed (3) Staying in EXCEL, open the spreadsheet file that needs delimited (4) Select/highlight the data/cells you want ported over (5) Hold these keys down in this sequence until you receive a message telling you how many records <CTRL> then <SHIFT> then <W> wait a few seconds and let go till you see the following

(6) Thats all now just Verify the record counts

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; ( Feel free to add a WHERE clause, etc )

COPYING TABLE FROM ONE MACHINE TO ANOTHER


First do a count or delete all your rows
SQL> select count(*) from jobxref; COUNT(*) --------4227 SQL> copy from apps/apps@argp > replace jobxref > using select * from jobxref;

or

create jobxref -

Array fetch/bind size is 15. (arraysize is 15) Will commit when done. (copycommit is 0) Maximum long size is 80. (long is 80) Table JOBXREF dropped. Table JOBXREF created. 4255 rows selected from apps@argp. 4255 rows inserted into JOBXREF. 4255 rows committed into JOBXREF at DEFAULT HOST connection. SQL> select count(*) from jobxref;

COUNT(*) --------4255

NOTE: initially be sure to do CREATE

SUPERB REFERENCE BOOK BY OREILLY


http://www.oreilly.com/catalog/orsqlloader/index.html http://www.oreilly.com/catalog/orsqlloader/chapter/ch01.html INTRODUCTION

SQL Loader is a tool used to import text formatted data into your database. This makes it easy to import your data from almost any database; all you have to do is export you data to a text file. SQL Loader comes with the Oracle client. SQL Loader with control file requires that you create a control file with the location of the data and how to import your data into Oracle.

DATATYPES SQL*Loader has a rich palette of datatypes. These datatypes are grouped into portable and nonportable datatypes. Within each of these two groups, the datatypes are subgrouped into length-value datatypes and value datatypes. Nonportable datatypes consist of: VALUE and LENGTH-VALUE datatypes. Portable datatypes consist of: CHAR, DATE, GRAPHIC, GRAPHIC EXTERNAL, Numeric External (INTEGER, FLOAT, DECIMAL, ZONED) and RAW

Direct Path Load vs. Conventional Path Load Method


SQL*Loader can use one of two methods to load data: conventional path (which uses the bind array) and direct path (which stores data directly into the database). The conventional path loader essentially loads the data by using standard insert statements. The direct path loader (direct=true) loads directly into the Oracle data files and creates blocks in Oracle database block format..

Conventional Path (default)


During conventional path loads, multiple data records are read in and placed in a bind array. When the bind array is full (or there is no more data left to read), it is passed to Oracle for insertion. Conventional path uses the Oracle SQL interface with the array option.

Direct Path
A direct path load creates data blocks that are already in Oracle database block format. These database blocks are then written directly to the database bypassing most RDBMS processing. This path is much faster than the conventional load, but entails several restrictions. To prepare the database for direct path loads, the script: $ORACLE_HOME/rdbms/admin/catldr.sql.sql must be executed. http://www.remote-dba.net/teas_rem_util18.htm

How to improve the performance of SQL*Loader? A very simple but easily overlooked hint is not to have any indexes and/or constraints (primary key) on your load tables during the load process. This will significantly slow down load times even with ROWS= set to a high value. Add the following option in the command line: DIRECT=TRUE. This will effectively bypass most of the RDBMS processing. However, there are cases when you can't use direct load. Turn off database logging by specifying the UNRECOVERABLE option. This option can only be used with direct data loads. Run multiple load jobs concurrently.

IMPORTANT: Log file will indicate any errors, constraints, duplication errors that occurred
Record 8: Rejected - Error on table EMP, --EMPNO null ORA-01400: mandatory (NOT NULL) column is missing or NULL during insert Record 9: Rejected - Error on table EMP. --EMPNO not unique ORA-00001: unique constraint (SCOTT.EMPIX) violated

SQL*Loader sometimes called ( Oracle Bulk Loader )


Look for sqlldr.exe (DOS) or sqlldr (UNIX) program in your BIN directory You would need to navigate to your bin directory in the oracle home directory to launch sqlldr. the control and data files will exist in the home directory of the logged in user..

Program sqlload sqlldr sqlldr73.exe sqlldr80.exe sqlldr.exe

Operating System Unix 8.0 Unix 8i Oracle Version 7.3 Oracle Version 8.0 Oracle Version 8i & above

$ORACLE_HOME/bin/sqlldr username/password@service_name control=name.ctl log=name.log data=filename.txt

(Unix) $ cd $ORACLE_HOME/bin (Unix) $ sqlldr sqlldr control=load.ctl log=load.log bad=load.log

The above thing will work if $oracle_home/bin is mentioned in the path of .profile file. You can customize the filename of your log file and error file or let sqlldr take care of it

Beware of SQL*LoaderSQL*Loader-625: Multibyte character error in control file You might have pressed backspace or an unprintable character somewhere in your control file. You might want to re-type the lines using NOTEPAD, TEXTPAD or a generic editor Dont use MS WORD or WORDPAD for SQL*Loader files!!! 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.

10

Create a control file. This is a simple text file with the following information: The location of the datafile The table to import the data into How the fields are terminated The name and format for the columns to create

The following is an example control file: Assuming your table is currently empty, you may begin by making a control file. This example can be custom-tailored to fit your needs.
LOAD DATA infile 'people.txt' INTO TABLE tablename FIELDS TERMINATED BY '|' TRAILING NULLCOLS ( first_name, last_name, age )

The last phrase tells the sqlldr which order the fields are listed in. The terminated keyword tells how the data fields are delimited; in this case the pipe character was used. The file 'people.txt' was used to contain the pipe delimited information, as shown here: jackie|chan|48 bruce|lee|32 jet|li|39 Once your control and data files are ready, use this line to tell sqlldr which control file to run. If you're importing many records at once, it may pause briefly to report that it's reached a commit point: UNIX: unix% sqlldr userid=username control=controlfilename.ctl DOS:

Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\>cd orant C:\orant>cd oracle9i C:\orant\oracle9i>cd bin C:\orant\oracle9i\bin> sqlldr userid=username control=controlfilename.ctl

11

OTHER EXAMPLES OF SQL*LOADER FEATURES


(1) Divide your amount by 100 This is helpful when you have field that are dollars with implied decimals examples: 10000 = 100.00 05623 = 56.23
LOAD DATA INFILE 'month.dat' INTO TABLE register (tx_type POSITION(1:10), acct POSITION(13:17),

amt
)

POSITION(20:24) ":amt/100"

(2) How to load a file but SKIP over a field you dont want This is a frequently asked question. How can you take a file full of delimited data and load just some of the columns, skipping over fields you don't want. You cannot use POSTION(x:y) because it is stream data, and there are no positional fields -- the next field begins after some delimiter, not in column X. Prior to Oracle8i, release 8.1, SQLLDR cannot do this without some help. In Oracle8i, release 8.1 the keyword FILLER was added to SQLLDR so that:

LOAD DATA INFILE * TRUNCATE INTO TABLE T FIELDS TERMINATED BY ',' ( field1,

field2 FILLER,
field3 )

BEGINDATA
a,b,c d,,g

The results from this control file that would load the the values a and c, skipping over b.

12

(3) Embed the Control card with data instead of having it separate file

Loading Without a Separate Data File


It is possible to use just the control file to load data, instead of using a separate data file. Here is an exampl
We want to load the data into the following table: SQL> CREATE TABLE load_user_positional 2 (username CHAR(30), 3 data1 NUMBER, 4 data2 CHAR(15) ); The control file would look like: LOAD DATA INFILE * INTO TABLE load_user_positional (username "USER" data1 POSITION(1:5), data2 POSITION(6:15), ) BEGINDATA 11111AAAAAAAAAA 22222BBBBBBBBBB

The trick is to specify "*" as the name of the data file, and use BEGINDATA to start the data section in the control file.

If we run SQL*Loader as username scott: $ SQLLDR scott/tiger load_user_d.ctl Our table data looks like: SQL> SELECT * FROM load_user_positional; USERNAME DATA1 DATA2 -------------- ---------- --------------SCOTT 11111 AAAAAAAAAA SCOTT 22222 BBBBBBBBBB

13

(4) Loading Constants, Dates, Converting and functions

LOAD DATA INFILE '****.txt' REPLACE INTO TABLE test FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' (

LAST_NAME position(1:7) CHAR "UPPER(:LAST_NAME)", FIRST_NAME position(8:15) CHAR "LOWER(:FIRST_NAME)" astrgk astamm aadrplz POSITION (37:61) POSITION (62:71) POSITION (72:77)

uppercase Last Name lowercase First Name

CHAR "UPPER(LTRIM(RTRIM(:astrgk)))", CHAR, INTEGER EXTERNAL, Sequencing starting at 1 Numeric 10 Oracle will store as 05-MAR-06

ROW_NUMBER ACTION_ID REPORT_DATE filedate REPORT_DATE username CREATED_BY CREATION_DATE ROUTING_DAYS )

SEQUENCE(1,1), CONSTANT 10, CONSTANT '20060305', constant '24-JUN-02',

DATE TO_DATE('20060305','YYYYMMDD') "USER" CONSTANT "-1", SYSDATE, CONSTANT "0" SQLLDR scott/tiger load_user_d.ctl would store scott Oracles system date literal 0

14

(5) Loading NULLs Entering NULL Values You may specify NULL values simply by entering fields in your data file without content. Keep in mind that any primary keys or other constraints requiring that values be non-NULL will reject tuples for which those attributes are unspecified. Depending how you have your data delimited two delimiters in sequence means NULL is the value Example:

WE HAVE 4 FIELDS/COLUMNS delimited by commas :


CITY STATE ZIP CODE COUNTRY

BROOKLYN,NY,10021, - country is NULL NEW YORK,NY,10004,USA - all fields populated BEVERLY HILLS,,90210,USA - state is NULL BEVERLY HILLS,NULL,90210,USA - state is NULL HOLLYWOOD,CA,NULL,USA - zip code is NULL Note: for the last record the constant NULL was used instead of the comma for zipcode. Either one works as long a field is defined NOT NULL

15

Fixed-length vs. delimited files?


A fixed-length file has a specified number of bytes for each column in the table. For example, if the specification is for 50 bytes and there are only 20 bytes in the record's column, 30 blank spaces will be appended. This way Oracle knows which byte range to look at for each column.
Loading Fixed-Format Fields The control file is ulcase2.ctl. LOAD DATA INFILE 'ulcase2.dat' INTO TABLE emp (empno POSITION(01:04) INTEGER EXTERNAL, ename POSITION(06:15) CHAR, job POSITION(17:25) CHAR, mgr POSITION(27:30) INTEGER EXTERNAL, sal POSITION(32:39) DECIMAL EXTERNAL, comm POSITION(41:48) DECIMAL EXTERNAL, deptno POSITION(50:51) INTEGER EXTERNAL)

7782 7839 7934 7566 7499 7658 7654

CLARK MANAGER KING PRESIDENT MILLER CLERK JONES MANAGER ALLEN SALESMAN CHAN ANALYST MARTIN SALESMAN

7839 2572.50 5500.00 7782 920.00 7839 3123.75 7698 1600.00 300.00 7566 3450.00 7698 1312.50 1400.00

10 10 10 20 30 20 30

One BIG drawback is if you have to insert a new field/column or your provider changes your layout you have to change everything unlike having DELIMITERS where you you simply move, add or delete the column field!!! Also tab delimiting is common but cannot be translated well

A delimited file has a special character (usually a tab, comma, bracket, pipe) separating each column for each record. The character shouldn't be used within the data, so if there's a text field that might contain tabs, developers generally choose a different character as the delimiter. Non-Oracle products generally use more delimited files than fixed-length files.
LOAD DATA INFILE 'ulcase2.dat'

FIELDS TERMINATED BY '|' TRAILING NULLCOLS


INTO TABLE emp (empno, ename, job, mgr, sal, comm, deptno)

7782|CLARK MANAGER|7839|2572.50||10 7839|KING PRESIDENT||5500.00||10 7934|MILLER CLERK|7782|920.00||10 7566|JONES MANAGER|7839|3123.75||20 7499|ALLEN SALESMAN|7698|1600.00|300.00|30 7658|CHAN ANALYST|7566|3450.00||20 7654|MARTIN SALESMAN|7698|1312.50|1400.00|30

16

Loading into Non-Empty Database Tables


SQL*Loader does not update existing records, even if they have null columns. If the tables you are loading already contain data, you have three choices for how SQL*Loader should proceed: INSERT - This is the default option. It requires the table to be empty before loading. SQL*Loader terminates with an error if the table contains rows. APPEND - If data already exists in the table, SQL*Loader appends the new rows to it; if data doesn't already exist, the new rows are simply loaded. REPLACE - All rows in the table are deleted and the new data is loaded. This option requires DELETE privileges on the table. You can create one logical record from multiple physical records using CONCATENATE and CONTINUEIF.

Loading Logical Records into Tables


The INTO TABLE clause allows you to tell which table you want to load data into. To load multiple tables, you would include one INTO TABLE clause for each table you wish to load. The INTO TABLE clause may continue with some options for loading that table. For example, you may specify different options (INSERT, APPEND, REPLACE) for each table in order to tell SQL*Loader what to do if data already exists in the table. The WHEN clause appears after the table name, and is followed by one or more field conditions. For example, the following clause indicates that any record with the value ``q'' in the fifth column position should be loaded: WHEN (5) = 'q'

17

STEP BY STEP EXAMPLE:


SQL> DESC JOBXREF_UTS Name Null? ------------------------------- -------JOBNO REIMB STATUS DESCR Type ---VARCHAR2(5) VARCHAR2(1) VARCHAR2(1) VARCHAR2(50)

In: C:\orant\oracle9i\bin jobcode_uts.ctl


LOAD DATA infile 'c:\ c:\job_uts.txt job_uts.txt' replace INTO TABLE jobxref_uts FIELDS TERMINATED BY '|' ( jobno, reimb, status, descr )

c:\job_uts.txt
00000|N|A|FLAGGING DIVERSIONS COST NOT ACCEPTABLE IN TIMEKEE 00001|N|A|TEST FOR CITY HALL ACCIDENT ON 8/22/95 00002|N|A|UMTA PROJ GRANT # 17-06-0102 SPONSOR'S CONT #TSC00010|N|A|TAMPING-ALL LINES-ALL TRACKS 00018|N|A|COSTS INCURRED FOR TRACTION GEL PLUS ANDELECTRAS G 00027|N|A|COSTS ASSOC W/HOURLY/ANNUAL TIMEKEEPING 00031|N|A|INFRASTRUCTURE MATERIAL ACQUISITION 00039|N|A|PARSONS/BRINKERHOFF CONSULTANT STUDY FORSIGNAL MOD 00076|N|A|NORMAL REPLACEMENT (TA POLICY FOR PC PRINTER 00077|N|A|DP SUPPLIES (SOFTWARE MEMORY DISKETTES ETC) DEPT 00078|N|A|COSTS ASSOC WITH IN-BETWEEN STATION CLEANING 00092|N|A|CRANE INSPECTIONS 00093|N|A|MTCE&REPAIR OF 1 TON CRANES 00094|N|A|MTCE&REPAIR OF 3 TON CRANES 00095|N|A|MTCE&REPAIR OF 10 TON CRANES 00096|N|A|MTCE&REPAIR OF TAMPERS 00097|N|A|MTCE REPAIR OF BALLAST REGULATORS

18

In DOS shell or Unix shell:


Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp.

C:\>CD

orant\ orant\oracle9i oracle9i\ 9i\bin APPS/APPS@ARGP JOBCODE_UTS


All rights reserved.

C:\orant\oracle9i\bin>SQLLDR

SQL*Loader: Release 9.2.0.1.0 - Production on Fri Jan 19 17:14:28 2007 Copyright (c) 1982, 2002, Oracle Corporation. Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count

64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024 1088 1152 1216 1280 1344 1408 1472 1536 1600 1664 1728 1792 1856 1920 1984 2048 2112 2176 2240 2304 2368 2432 2496 2560 2624 2688 2752 2816 2880 2944 3008 3072 3136 3200 3235

C:\orant\oracle9i\bin>

19

In: C:\orant\oracle9i\bin jobcode_uts.log is automatically generated unless you give it a different filename
SQL*Loader: Release 9.2.0.1.0 - Production on Fri Jan 19 17:14:28 2007 Copyright (c) 1982, 2002, Oracle Corporation. Control File: JOBCODE_UTS.ctl Data File: c:\job_uts.txt Bad File: job_uts.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 256000 bytes none specified Conventional All rights reserved.

Table JOBXREF_UTS, loaded from every logical record. Insert option in effect for this table: REPLACE Column Name Position Len Term Encl Datatype ------------------------------ ---------- ----- ---- ---- --------------------JOBNO FIRST * | CHARACTER REIMB NEXT * | CHARACTER STATUS NEXT * | CHARACTER DESCR NEXT * | CHARACTER Table JOBXREF_UTS: 3235 Rows 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: Read buffer bytes: 1048576 Total Total Total Total logical logical logical logical records records records records skipped: read: rejected: discarded: 0 3235 0 0 66048 bytes(64 rows)

Run began on Fri Jan 19 17:14:28 2007 Run ended on Fri Jan 19 17:14:30 2007 Elapsed time was: CPU time was: 00:00:01.92 00:00:00.08

20

BELOW IS AN EXAMPLE OF HOW TO SCRIPT AND AUTOMATE THE LOAD PROCESS [ RUN THIS SCRIPT IN A DOS SHELL ] uts_comspec.bat load_uts.bat
ECHO. RE LOAD UTS JOBCODE TABLE ON ARGP ECHO. RE LOAD UTS JOBCODE TABLE ON ARGP ECHO. RE LOAD UTS JOBCODE TABLE ON ARGP echo. echo. echo. - c:\uts_comspec.bat echo. echo. IGNORE ALL MESSAGES UNLESS THE PROCESS echo. UNEXPECTEDLY SHOULD STOP PROCESSING echo. echo. echo. P R O C E S S S T A R T I N G %comspec% /c load_uts > argp_UTS_JOBCODE.txt echo. echo. echo. P R O C E S S C O M P L E T E D echo. echo. echo press ENTER to close this window echo. echo. pause exit echo. echo. UTS Jobocodes LOAD into table jobxref_uts echo. ECHO. DELETING C:\UTS_JOBCODES.TXT echo. del /f c:\uts_jobcodes.txt echo. file is deleted echo. ECHO. starting FTP from security to APPS ftp -s:C:\FTP_commands_uts.txt ECHO. FTP completed echo. echo. starting SQL Loader load cd \ echo. CD orant\oracle9i\bin\ echo. CD orant\oracle9i\bin\ sqlldr apps/apps@argp jobcode_uts cd \ echo. echo. UTS Jobocodes LOAD completed

ftp_commands_uts.txt

jobcode_uts.CTL

open 10.8.37.44 <ACCOUNT> <PASSWORD> pwd dir get job_uts.txt c:\uts_jobcodes.txt pwd quit

LOAD DATA infile 'c:\job_uts.txt' replace INTO TABLE jobxref_uts FIELDS TERMINATED BY '|' ( jobno, reimb, status, descr )

21

C:\

argp_UTS_JOBCODE.txt

C:\>echo. C:\>echo. UTS Jobocodes LOAD into table jobxref_uts UTS Jobocodes LOAD into table jobxref_uts C:\>echo. C:\>ECHO. DELETING C:\UTS_JOBCODES.TXT DELETING C:\UTS_JOBCODES.TXT C:\>echo. C:\>del /f c:\uts_jobcodes.txt C:\>echo. file is deleted file is deleted C:\>echo. C:\>ECHO. starting FTP from security to APPS starting FTP from security to APPS C:\>ftp -s:C:\FTP_commands_uts.txt ftp> Connected to 10.8.37.44. open 10.8.37.44 220-FTP server ready. 220 This is a private system - No anonymous login User (10.8.37.44:(none)): 331 User pcprodar OK. Password required 230-User pcprodar has group access to: finance nyct 230 OK. Current restricted directory is / ftp> Invalid command. ftp> pwd 257 "/" is your current location ftp> dir 200 PORT command successful 150 Connecting to port 3118 -rw-r--r-1 pcprodar nyct 197579 Jan 16 09:55 job_uts.txt -rw-r--r-1 pcprodar nyct 332820 Jan 15 23:01 jobdesc.txt -rw-r--r-1 pcprodar nyct 22713 Dec 27 16:26 jspread.txt -rw-r--r-1 pcprodar nyct 159689 Dec 27 16:27 summary.txt -rw-r--r-1 pcprodar nyct 8320444 Dec 27 16:27 sysout.txt -rw-r--r-1 pcprodar nyct 87966 Jan 15 23:01 xrc.txt 226-Options: -l 226 21 matches total ftp: 1496 bytes received in 0.00Seconds 1496000.00Kbytes/sec. ftp> get job_uts.txt c:\uts_jobcodes.txt 200 PORT command successful 150-Connecting to port 3119 150 192.9 kbytes to download 226-File successfully transferred 226 0.171 seconds (measured here), 1.10 Mbytes per second ftp: 200818 bytes received in 0.20Seconds 989.25Kbytes/sec. ftp> pwd 257 "/" is your current location ftp> quit 221-Goodbye. You uploaded 0 and downloaded 193 kbytes. 221 Logout - CPU time spent: 0.000 seconds. C:\>ECHO. FTP completed FTP completed C:\>echo. C:\>echo. starting SQL Loader load starting SQL Loader load C:\>cd \ C:\>echo. CD orant\oracle9i\bin\ CD orant\oracle9i\bin\ C:\>echo. C:\>CD orant\oracle9i\bin\

22

C:\orant\oracle9i\bin>sqlldr apps/apps@argp jobcode_uts SQL*Loader: Release 9.2.0.1.0 - Production on Tue Jan 16 17:17:25 2007 Copyright (c) 1982, 2002, Oracle Corporation. Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count All rights reserved.

64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024 1088 1152 1216 1280 1344 1408 1472 1536 1600 1664 1728 1792 1856 1920 1984 2048 2112 2176 2240 2304 2368 2432 2496 2560 2624 2688 2752 2816 2880 2944 3008 3072 3136 3200 3235

C:\orant\oracle9i\bin>cd \ C:\>echo. C:\>echo. UTS Jobocodes LOAD completed UTS Jobocodes LOAD completed

23

BELOW IS AN EXAMPLE OF HOW TO SCRIPT AND AUTOMATE THE LOAD PROCESS

C:\

argp_UTS_JOBCODE.txt

C:\>echo. C:\>echo. UTS Jobocodes LOAD into table jobxref_uts UTS Jobocodes LOAD into table jobxref_uts C:\>echo. C:\>ECHO. DELETING C:\UTS_JOBCODES.TXT DELETING C:\UTS_JOBCODES.TXT C:\>echo. C:\>del /f c:\uts_jobcodes.txt C:\>echo. file is deleted file is deleted C:\>echo. C:\>ECHO. starting FTP from security to APPS starting FTP from security to APPS C:\>ftp -s:C:\FTP_commands_uts.txt ftp> Connected to 10.8.37.44. open 10.8.37.44 220-FTP server ready. 220 This is a private system - No anonymous login User (10.8.37.44:(none)): 331 User pcprodar OK. Password required 230-User pcprodar has group access to: finance nyct 230 OK. Current restricted directory is / ftp> Invalid command. ftp> pwd 257 "/" is your current location ftp> dir 200 PORT command successful 150 Connecting to port 3118 -rw-r--r-1 pcprodar nyct 197579 Jan 16 09:55 job_uts.txt -rw-r--r-1 pcprodar nyct 332820 Jan 15 23:01 jobdesc.txt -rw-r--r-1 pcprodar nyct 22713 Dec 27 16:26 jspread.txt -rw-r--r-1 pcprodar nyct 159689 Dec 27 16:27 summary.txt -rw-r--r-1 pcprodar nyct 8320444 Dec 27 16:27 sysout.txt -rw-r--r-1 pcprodar nyct 87966 Jan 15 23:01 xrc.txt 226-Options: -l 226 21 matches total ftp: 1496 bytes received in 0.00Seconds 1496000.00Kbytes/sec. ftp> get job_uts.txt c:\uts_jobcodes.txt 200 PORT command successful 150-Connecting to port 3119 150 192.9 kbytes to download 226-File successfully transferred 226 0.171 seconds (measured here), 1.10 Mbytes per second ftp: 200818 bytes received in 0.20Seconds 989.25Kbytes/sec. ftp> pwd 257 "/" is your current location ftp> quit 221-Goodbye. You uploaded 0 and downloaded 193 kbytes. 221 Logout - CPU time spent: 0.000 seconds. C:\>ECHO. FTP completed FTP completed C:\>echo. C:\>echo. starting SQL Loader load starting SQL Loader load C:\>cd \ C:\>echo. CD orant\oracle9i\bin\

24

CD orant\oracle9i\bin\ C:\>echo. C:\>CD orant\oracle9i\bin\ C:\orant\oracle9i\bin>sqlldr apps/apps@argp jobcode_uts SQL*Loader: Release 9.2.0.1.0 - Production on Tue Jan 16 17:17:25 2007 Copyright (c) 1982, 2002, Oracle Corporation. Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit Commit point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point point reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached reached logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical logical record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record record count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count count All rights reserved.

64 128 192 256 320 384 448 512 576 640 704 768 832 896 960 1024 1088 1152 1216 1280 1344 1408 1472 1536 1600 1664 1728 1792 1856 1920 1984 2048 2112 2176 2240 2304 2368 2432 2496 2560 2624 2688 2752 2816 2880 2944 3008 3072 3136 3200 3235

C:\orant\oracle9i\bin>cd \ C:\>echo. C:\>echo. UTS Jobocodes LOAD completed UTS Jobocodes LOAD completed

25

Assorted SQL*Loader links and references


FAQs http://www.orafaq.com/faq/sql_loader Oracle FAQs SQL*Loader & A comparative analysis between SQL*LOADER and UTL_FILE utility http://orafaq.com/papers/sqlload.doc Oracle SQL*Loader FAQ http://orafaq.com/faqloadr.htm SOLUTIONS TO COMMON SQL*LOADER QUESTIONS http://www.fors.com/orasupp/rdbms/utils/140121_1.HTM Oracle SQL*Loader The Definitive Guide (OReilly BOOK) http://www.oreilly.com/catalog/orsqlloader/chapter/ch01.html Oracle SQL*Loader The Definitive Guide (BOOK) http://ftp.ora.com/orsqlloader/ Oracle SQL*Loader: The Definitive Guide Examples (ZIP file) http://www.oreilly.com/catalog/orsqlloader/chapter/ch01.html Chapter 1 Introduction to SQL*Loader References http://www.csee.umbc.edu/help/oracle8/server.815/a67792/ch06.htm SQL*Loader Command-Line Reference http://www.csee.umbc.edu/help/oracle8/server.815/a67792/ch05.htm SQL*Loader Control File Reference http://www.csee.umbc.edu/help/oracle8/server.815/a67792/ch04.htm SQL*Loader Case Studies & Examples http://docs.linux.cz/databases/Oracle8/server/a58244/apa.htm SQL Loader Reserved Words http://www.psoug.org/reference/sqlloader.html SQL Loader Version 10.2

http://infolab.stanford.edu/~ullman/fcdb/oracle/or-load.html Using the Oracle Bulk Loader http://www.oracleutilities.com/OSUtil/sqlldr.html Loading large datasets into oracle 8i tables from unix & windows http://www.cdpr.ca.gov/docs/empm/pubs/sops/data002.00.pdf http://www.dba-oracle.com/t_optimize_sql_loader_sqlldr_performance.htm Replacing 3GL Data Loading with SQL*Loader and Database Triggers http://www.rumken.com/ioug2000/Paper421.htm

Only UNIX:
Oracle UNIX Commands SQL Loader www.rocket99.com/techref/oracle8317.html SQL*Loader Control File Reference (UNIX) http://www.lc.leidenuniv.nl/awcourse/oracle/server.920/a96652/ch04.htm Unix examples http://www.princeton.edu/~storacle/sqlloader_demo.shtml Oracle Tips http://www.akadia.com/services/ora_important_part_2.html Automating SQL*LDR http://www.oracledbaexpert.com/oracle/oracleSQLLDRAutomation.html

26

NOTES & QUESTIONS

By George Lewycky TIS-Financial 646 252 8882 george.lewycky@nyct.com Friday, February 02, 2007 Oracle Tips_Pausche 7.1.doc Monday, February 12, 2007 Oracle Tips_Pausche 8.0doc.doc

27

You might also like