When we want to load long descriptions it is always challenging to handle new line character.
Found following good solution in one of the Oracle forum.
LOAD
INFILE 'create_prober_items.csv'
CONTINUEIF LAST '"'
INTO TABLE MTL_SYSTEM_ITEMS_INTERFACE
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
(PROCESS_FLAG "TRIM(:PROCESS_FLAG)",
SET_PROCESS_ID "TRIM(:SET_PROCESS_ID)",
TRANSACTION_TYPE "TRIM(:TRANSACTION_TYPE)",
ORGANIZATION_ID "TRIM(:ORGANIZATION_ID)",
TEMPLATE_ID "TRIM(:TEMPLATE_ID)",
SEGMENT1 "TRIM(:SEGMENT1)",
SEGMENT2 "TRIM(:SEGMENT2)",
DESCRIPTION "TRIM(:DESCRIPTION)",
LONG_DESCRIPTION "REPLACE (TRIM(:LONG_DESCRIPTION), '-', CHR(10) || '-')")
The CONTINUEIF LAST '"' tells it to continue with the next row as part of the same logical record if the last character of the current row is not ". When it gets to a row then ends with ", then it knows that is the end of the record.
The "REPLACE (TRIM(:LONG_DESCRIPTION), '-', CHR(10) || '-')" tells it to add a carriage return or line feed in front of each hyphen, so that it is displayed with each hyphen starting on a newline, as you requested.
Found following good solution in one of the Oracle forum.
LOAD
INFILE 'create_prober_items.csv'
CONTINUEIF LAST '"'
INTO TABLE MTL_SYSTEM_ITEMS_INTERFACE
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
(PROCESS_FLAG "TRIM(:PROCESS_FLAG)",
SET_PROCESS_ID "TRIM(:SET_PROCESS_ID)",
TRANSACTION_TYPE "TRIM(:TRANSACTION_TYPE)",
ORGANIZATION_ID "TRIM(:ORGANIZATION_ID)",
TEMPLATE_ID "TRIM(:TEMPLATE_ID)",
SEGMENT1 "TRIM(:SEGMENT1)",
SEGMENT2 "TRIM(:SEGMENT2)",
DESCRIPTION "TRIM(:DESCRIPTION)",
LONG_DESCRIPTION "REPLACE (TRIM(:LONG_DESCRIPTION), '-', CHR(10) || '-')")
The CONTINUEIF LAST '"' tells it to continue with the next row as part of the same logical record if the last character of the current row is not ". When it gets to a row then ends with ", then it knows that is the end of the record.
The "REPLACE (TRIM(:LONG_DESCRIPTION), '-', CHR(10) || '-')" tells it to add a carriage return or line feed in front of each hyphen, so that it is displayed with each hyphen starting on a newline, as you requested.
No comments:
Post a Comment