Salesforce

How to store XML in a database using the least amount of storage?

« Go Back

Information

 
TitleHow to store XML in a database using the least amount of storage?
URL NameHow-to-store-XML-in-a-database-using-the-least-amount-of-storage
Article Number000116874
EnvironmentProduct: OpenEdge
Version: All supported versions
OS: All supported platforms
Question/Problem Description
How to store XML in a database using the least amount of storage?

What is the best way to store a normal (ASCII) XML file into the database with minimal database size?

Storing XML files in the database with minimal storage capacity.

How to store files in a database using the least amount of storage?
Steps to Reproduce
Clarifying Information
Files can be stored in the database using LOB fields.
 
Error Message
Defect Number
Enhancement Number
Cause
Resolution
Use CREATE X-DOCUMENT or COPY-LOB FROM FILE to copy XML into the database field. 

The following code shows both options (choose one):
DEFINE VARIABLE MyLongCharVariable AS LONGCHAR NO-UNDO. 
DEFINE VARIABLE hXDoc AS HANDLE NO-UNDO. 

DEFINE TEMP-TABLE ttTemp NO-UNDO 
       FIELD MyClobField AS CLOB.

CREATE ttTemp. 

/* From X-DOCUMENT to LONGCHAR to CLOB */
CREATE X-DOCUMENT hXDoc.
hXDoc:LOAD("FILE", "example.xml", FALSE).
hXDoc:SAVE("LONGCHAR", MyLongCharVariable).
COPY-LOB MyLongCharVariable TO ttTemp.MyClobField.

/* From file to CLOB */
COPY-LOB FROM FILE "example.xml" TO ttTemp.MyClobField.

To further reduce space, the file could also be compressed/zipped before being stored in the database.
Progress does not provide any built-in methods to zip files but third-party libraries are available for this.
Workaround
Notes
References to other documentation:

Progress article(s):
 Best practices with BLOB/CLOB fields
 How to report of the space used by LOBS?
Keyword Phrase
Last Modified Date11/20/2020 7:02 AM

Powered by