-1

I'm trying to save and load an Object into a database Field of type BLOB. Is this possible? And if yes, how?

Example:

Saving an instance of vk.class.Offer.cls to DB-Table OfferHead
and loading objOffer of type vk.class.Offer.cls from DB-Table OfferHead.

I'm trying the following code:

   DEFINE VARIABLE objAngebot AS CLASS vk.class.Angebot NO-UNDO.
   DEFINE VARIABLE oObj       as MemPTR                 NO-UNDO.

   DEFINE BUFFER bAngKopf FOR AngKopf.

   COPY-LOB  bAngKopf.ank_ObjHandle TO oObj.
   objAngebot = CAST(oObj, vk.class.Angebot). 
J. Mennig
  • 25
  • 5
  • 1
    I think the term you are looking for is *serialize*, and there is information for Progress OpenEdge in [Serializing classes to binary and JSON formats](https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/gspub/serializing-classes-to-binary-and-json-formats.html). – Andrew Morton Aug 06 '20 at 10:39
  • 2
    What are you trying that isn’t working? Are there error messages or other helpful clues regarding what is going wrong with those attempts? – Tom Bascom Aug 06 '20 at 11:12

1 Answers1

0

I got it working by writing the Object to a file and rereading it back into DB.

COPY-LOB FROM bAngPos.anp_ObjHandle TO FILE cPfadPos.
  objInputStream = NEW Progress.IO.FileInputStream(cPfadPos).
  objSerializer = NEW Progress.IO.BinarySerializer().
  objAngebotPos = CAST(objSerializer:Deserialize(objInputStream), vk.class.AngebotPos) NO-ERROR.
  objInputStream:Close().
  OS-DELETE VALUE(cPfadPos).
J. Mennig
  • 25
  • 5