CraigJConrad
IS-IT--Management
A couple of weeks ago, I asked about extracting data from Oracle into fixed-format flat files. I received a very helpful reply from Mufasa (Dave) that gave a precise method for doing this. While I am now much smarter regarding SQL, my knowledge pales to those on this group, so please be gentle with me if I am asking stupid questions!
Now I have a similar issue with loading an Oracle database, where the input is coming from flat ascii files, with each field/record being of a fixed length. In other words, these are NOT CSV files. Let me offer a simple example of the layout of the flat file:
NAME Bytes 1 to 20
ADDRESS Bytes 21 to 50
SALARY Bytes 51 to 59
Therefore, an example of the file would be (assume that Tom makes $45,123.00 salary, and Mary makes $52,423.00):
Let's assume that I need to load this data into Oracle table named "Client_Table", with columns "Name", "Address" and "Salary", defined respectively as VARCHAR(20), VARCHAR(30), and NUMBER(9,2).
In z-OS DB2, there is a utility that performs this. The input would be something like:
How would I accomplish this in the Oracle world? Do I need to do some kind of import to a new table, treating each record as a row having a single CHAR, then use SQL scripts to select each one (subquery) and drive an UPDATE to the real table (use of substr to pick out the fields) from each?
Now I have a similar issue with loading an Oracle database, where the input is coming from flat ascii files, with each field/record being of a fixed length. In other words, these are NOT CSV files. Let me offer a simple example of the layout of the flat file:
NAME Bytes 1 to 20
ADDRESS Bytes 21 to 50
SALARY Bytes 51 to 59
Therefore, an example of the file would be (assume that Tom makes $45,123.00 salary, and Mary makes $52,423.00):
Code:
000000000011111111112222222222333333333344444444445555555555
012345678901234567890123456789012345678901234567890123456789
TOM PETERS 56 MAPLE STREET 004512300
MARY HART 436 PINE STREET 005242300
Let's assume that I need to load this data into Oracle table named "Client_Table", with columns "Name", "Address" and "Salary", defined respectively as VARCHAR(20), VARCHAR(30), and NUMBER(9,2).
In z-OS DB2, there is a utility that performs this. The input would be something like:
Code:
LOAD DATA RESUME YES LOG NO NOCOPYPEND DISCARDDN DISCARD INTO TABLE QHJL003.CLIENT_TAB
(NAME POSITION(01) CHAR(20) ,
ADDRESS POSITION(21) CHAR(20) NULLIF(21)=' ',
SALARY POSITION(51) NUMBER(9,2))
How would I accomplish this in the Oracle world? Do I need to do some kind of import to a new table, treating each record as a row having a single CHAR, then use SQL scripts to select each one (subquery) and drive an UPDATE to the real table (use of substr to pick out the fields) from each?