Consultor Eletrônico



Kbase P159169: How to store a Microsoft .docx document in a blob field
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/11/2010
Status: Verified

GOAL:

How to store a Microsoft .docx document in a blob field

GOAL:

How to use the COPY-LOB statement to copy a lob field to a file and vice versa

GOAL:

How to create a Word document.

FACT(s) (Environment):

Windows
OpenEdge 10.x

FIX:

The following is an example of how to store a .docx document in a BLOB field then read it and save it as a new docx file.
DEF VAR lcLongChar AS LONGCHAR.
DEF VAR mPtr AS MEMPTR.

/* Open file */
COPY-LOB FILE "<dir><file-name.docx>" TO mPtr.
lcLongChar = BASE64-ENCODE(mPtr).

/* Saving data */
CREATE <table-name>.
ASSIGN <table>.< blob-field > = base64-decode(lcLongChar).

/* Reading and creating new file */
COPY-LOB FROM <table>.<blob-field> TO FILE "<dir><output new-file-name.docx>".
set-size(mPtr) = 0.