Home » SQL & PL/SQL » SQL & PL/SQL » How To Add Full Email Body Text from File to CLOB Column? (Oracle 12c)
How To Add Full Email Body Text from File to CLOB Column? [message #679818] Wed, 01 April 2020 15:53 Go to next message
Messages: 8
Registered: April 2020
Junior Member
I have a Python script which does the following:
- Cycles through incoming messages in an email inbox every few min.
- Saves the content of the body of each email msg. as individual .txt files for each email msg.
- Accesses each .txt file afterwards for purposes of parsing through the contents of ea. file in identifying pertinent data contained within ea. .txt file
- Saves the pertinent info. from ea. .txt file to an Oracle database table

The problem I'm having is with an "EmailBody" column in Oracle (it's a CLOB column). We erase each email once it's determined that the emails have been successfully saved to .txt files that will be soon processed by the Python script. With that in mind, should something with the insertion of data from the .txt files into Oracle not go entirely correct, we want to have the full email body saved to the "EmailBody" column so we can revisit the full email in this manner from the CLOB column and reprocess if if needed.

The .txt files that I'm creating from the emails are all very readable and have line breaks or carriage returns in all appropriate spots.

Once I insert the full email body text into the "EmailBody" column in Oracle and I go back to the "EmailBody" column to look at the text that's been inserted into that column, all of the data is basically jumbled together with the line feeds and/or carriage returns stripped.

Does anyone have experiencing having done this in the past or had this same challenge with the stripped line feed / carriage returns and come up with a solution as to how to insert contents from a .txt file accurately with all pre-existing line feed / carriage return characters in place in the Oracle CLOB column just like they were present in the original .txt file?

Thanks in advance for any info. anyone can provide.
Re: How To Add Full Email Body Text from File to CLOB Column? [message #679819 is a reply to message #679818] Thu, 02 April 2020 00:11 Go to previous message
Michel Cadot
Messages: 68038
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Something is wrong in your code so post it.
Before, Please read How to use [code] tags and make your code easier to read.
Indent the code, make sure that lines of code do not exceed 100 characters.
If you don't know how to format the code, learn it using SQL Formatter.

Previous Topic: Fill in records where date missing in sequence
Next Topic: getting finacial week number
Goto Forum:

Current Time: Fri Nov 26 23:54:28 CST 2021