anumoses
asked on
load oracle table from flat file
We will be getting data from flat file every morning. This data needs to be loaded to oracle table. I cannot create external table or create control file to load data to the table as this data needs to be loaded every day that has a sequence number.
LT_CERNER_ID is the sequence that gets created for every line during insert. What suggestions for me to get the data loaded?
LT_CERNER_ID is the sequence that gets created for every line during insert. What suggestions for me to get the data loaded?
CREATE TABLE LT_CERNER_INTER
(
LT_CERNER_ID NUMBER NOT NULL,
SOURCE_SYSTEM VARCHAR2(1 BYTE),
SHIP_TO_ID VARCHAR2(24 BYTE),
BILL_TO_ID VARCHAR2(24 BYTE),
SERVICE_CODE VARCHAR2(5 BYTE),
DEPT_NUMBER VARCHAR2(4 BYTE),
UNIT_NUMBER VARCHAR2(15 BYTE),
QTY NUMBER(17,2),
PRICE NUMBER(17,2),
EXTENDED_AMOUNT NUMBER(17,2),
DOCUMENT_TYPE VARCHAR2(2 BYTE),
SERVICE_DESCRIPTION VARCHAR2(50 BYTE),
PO_NUMBER VARCHAR2(30 BYTE),
BLOOD_ID VARCHAR2(15 BYTE),
PRODUCT_CODE VARCHAR2(8 BYTE),
ALIQUOT VARCHAR2(2 BYTE),
PRODUCT_ID VARCHAR2(25 BYTE),
PRODUCT_SHORT_NAME VARCHAR2(10 BYTE),
INVENTORY_PRODUCT_TYPE VARCHAR2(6 BYTE),
ABO_TYPE VARCHAR2(3 BYTE),
BRANCH_ID VARCHAR2(2 BYTE),
CUSTOMER_TYPE VARCHAR2(2 BYTE),
DOCUMENT_DATE DATE,
DOCUMENT_NO VARCHAR2(14 BYTE),
ORDER_DATE DATE,
ORDER_NO VARCHAR2(10 BYTE),
BIX_ID VARCHAR2(10 BYTE),
ORIGINAL_DOCUMENT_DATE DATE,
ORIGINAL_DOCUMENT_NO VARCHAR2(14 BYTE),
PATIENT_NAME VARCHAR2(30 BYTE),
DOCTOR_NAME VARCHAR2(30 BYTE),
VOLUME_LITERS NUMBER(17,3),
TRANSACTION_TYPE VARCHAR2(2 BYTE),
SORT_ORDER VARCHAR2(2 BYTE),
LOT_NUMBER VARCHAR2(30 BYTE),
LOT_NUMBER_EXP_DATE DATE,
IU NUMBER(17),
TOTAL_IU NUMBER(17),
NDC_CODE VARCHAR2(12 BYTE),
PHS_FLAG VARCHAR2(1 BYTE),
DERIVATIVE_ITEM_CODE VARCHAR2(12 BYTE),
REFERENCE_DATE DATE,
PATIENT_TYPE VARCHAR2(10 BYTE),
ADMIT_DOC_NAME_FIRST VARCHAR2(20 BYTE),
COLLECTION_DATE DATE,
COMMENTS VARCHAR2(80 BYTE),
CPT4_1 VARCHAR2(80 BYTE),
CPT4_2 VARCHAR2(80 BYTE),
DATE_OF_SERVICE DATE,
DONOR_NAME_FIRST VARCHAR2(20 BYTE),
DONOR_NAME_LAST VARCHAR2(20 BYTE),
FIN_CLASS VARCHAR2(10 BYTE),
MM VARCHAR2(10 BYTE),
OPI VARCHAR2(10 BYTE),
PATIENT_DOB DATE,
PATIENT_NAME_FIRST VARCHAR2(20 BYTE),
PATIENT_NAME_LAST VARCHAR2(20 BYTE),
PATIENT_NAME_MI VARCHAR2(20 BYTE),
SSN VARCHAR2(9 BYTE),
CLIENT_CODE VARCHAR2(6 BYTE),
PATIENT_FIN_NOR VARCHAR2(10 BYTE),
REQ_NO VARCHAR2(10 BYTE),
TEST_ALIAS VARCHAR2(10 BYTE),
TRANSPLANT_TYPE VARCHAR2(10 BYTE),
ICD9_CODES VARCHAR2(80 BYTE),
CREDIT_COMMENT_1 VARCHAR2(80 BYTE),
CREDIT_COMMENT_2 VARCHAR2(80 BYTE),
USER_DEFINED_FIELD_1 VARCHAR2(40 BYTE),
USER_DEFINED_FIELD_2 VARCHAR2(40 BYTE),
USER_DEFINED_FIELD_3 VARCHAR2(40 BYTE),
USER_DEFINED_FIELD_4 VARCHAR2(40 BYTE),
CREATED_BY VARCHAR2(30 BYTE),
CREATE_TIME DATE,
UPDATED_BY VARCHAR2(30 BYTE),
UPDATE_TIME DATE
)
CREATE UNIQUE INDEX LT_CERNER_INTER_PK ON LT_CERNER_INTER
(LT_CERNER_ID)
LOGGING
TABLESPACE PHBC_IDX1
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
)
NOPARALLEL;
CREATE OR REPLACE TRIGGER LT_CERNER_INTER_BI
before insert on LT_CERNER_INTER
for each row
declare
-- local variables here
begin
:new.LT_CERNER_ID := hbc_sequences_pkg.nextvalue('LT_CERNER_ID');
:new.create_time := Sysdate;
:new.created_by := User;
end LT_CERNER_INTER_BI;
/
SHOW ERRORS;
CREATE OR REPLACE TRIGGER LT_CERNER_INTER_BU
before update on LT_CERNER_INTER
for each row
declare
-- local variables here
begin
:new.update_time := Sysdate;
:new.updated_by := User;
end LT_CERNER_INTER_BU;
/
SHOW ERRORS;
CREATE PUBLIC SYNONYM LT_CERNER_INTER FOR LT_CERNER_INTER;
ALTER TABLE LT_CERNER_INTER ADD (
CONSTRAINT LT_CERNER_INTER_PK
PRIMARY KEY
(LT_CERNER_ID)
USING INDEX
TABLESPACE PHBC_IDX1
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
));
GRANT ALTER, DELETE, INSERT, SELECT, UPDATE, ON COMMIT REFRESH, QUERY REWRITE, DEBUG, FLASHBACK ON LT_CERNER_INTER TO HBC_USER;
GRANT ALTER, DELETE, INDEX, INSERT, REFERENCES, SELECT, UPDATE, ON COMMIT REFRESH, QUERY REWRITE, DEBUG, FLASHBACK ON LT_CERNER_INTER TO PUBLIC;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A couple of questions come to mind.
Is that one record? If so, will the real data be on 15 lines like that and not one?
There are TO_DATE functions in the data. Will the real data be like that?
Looking at the data, you cannot use a comma as a delimiter as there are function calls that have commas in them that aren't enclosed by double quotes.
If the sample record is what the actual sample data will look like, I would use editor tricks to turn it into insert statements. It really just needs the insert on the front and the closing parenthesis and semicolon on the end.
Is that one record? If so, will the real data be on 15 lines like that and not one?
There are TO_DATE functions in the data. Will the real data be like that?
Looking at the data, you cannot use a comma as a delimiter as there are function calls that have commas in them that aren't enclosed by double quotes.
If the sample record is what the actual sample data will look like, I would use editor tricks to turn it into insert statements. It really just needs the insert on the front and the closing parenthesis and semicolon on the end.
ASKER
Now that I have created external table, is there a way to add audit columns?
like create_time, created_by, update_time and updated_by? How do we also let the sequence add the next number to LT_CERNER_ID ?
I am still waiting for a sample file from the other company.
like create_time, created_by, update_time and updated_by? How do we also let the sequence add the next number to LT_CERNER_ID ?
I am still waiting for a sample file from the other company.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks and that was what I thought.
ASKER
Open in new window
Open in new window