Handling of LOB fields
 

Handling of LOB fields

6 posts, 2 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    23 Oct 2020
    Link to this post
    I have a form where we allow the user to select an image from disk and store the base64 encoded flavor in a CLOB. Right now I am storing that value in an ultratextbox and it will flow back to the server when we save changes. I would prefer not having a control on the form to store this. I was thinking using the DatasetController to GET/SET the value. The GET will work just fine...

    /*------------------------------------------------------------------------------
    Purpose:
    Notes:
    ------------------------------------------------------------------------------*/

    METHOD PUBLIC LONGCHAR GetImageData (  ):

    DEFINE VARIABLE lcImageData AS LONGCHAR NO-UNDO. 

    IF AVAILABLE eItemImage THEN 
    DO: 
    COPY-LOB FROM eItemImage.ImageData TO lcImageData.  
    RETURN lcImageData.
    END.   


    However,

    The SET does not appear to work. I will already be "ModifyingData" in the viewer. If I use the code below should that work where the value will get back to the server? If not what would be the best way to do this?

    /*------------------------------------------------------------------------------
    Purpose:
    Notes:
    ------------------------------------------------------------------------------*/

    METHOD PUBLIC VOID SetImageData ( plcImageData AS LONGCHAR ):

    IF AVAILABLE eItemImage THEN 
    DO: 
    COPY-LOB FROM plcImageData TO eItemImage.ImageData.  
    END.   

    RETURN.

    END METHOD.
    RETURN "".

    END METHOD.
  2. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    Answered
    23 Oct 2020 in reply to Roger Blanchard
    Link to this post
    What most likely happens is that the SmartBusinessEntityAdapter when collecting changes from the BindingSource overwrites the value again with the previous/empty value. This happens in UpdateRow in the SmartDatasetAdapter class. 

    You can set the NonUpdatableColumns property to exclude columns here. In your case, you should set that property to "ImageData".

  3. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    23 Oct 2020 in reply to Mike Fechner
    Link to this post
    Perfect!!!

    Thank you.
  4. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    01 Dec 2020 in reply to Mike Fechner
    Link to this post
    Mike,

    As a follow up to this LOB question we have logic shown below that will use COPY-LOB to copy the contents of a file on disk into a DB BLOB field. What is the best way to handle this when using a dataset model class? It looks like BLOB fields are not added to the TableModelClass.

    COPY-LOB FROM FILE cExportName TO Email.MailAttachment NO-CONVERT.
  5. Daniel van Doorn
    Daniel van Doorn avatar
    17 posts
    Registered:
    18 Jun 2018
    Answered
    02 Dec 2020 in reply to Roger Blanchard
    Link to this post
    Hi Roger,

    Since CLOBs and BLOBs cannot be defined as variable or property. We cannot support BLOB and CLOB as such in a DatasetModel class. 

    When you would have a CLOB field in your table, this is in the DatasetModel classes automatically converted to a longchar. That does not happen automatically for a BLOB. So you would need a calculated field for a BLOB. 

    Like that you can use something like oSalesrepDatasetModel:Salesrep:Image with the COPY-LOB statement.

    BR Daniel



  6. Roger Blanchard
    Roger Blanchard avatar
    381 posts
    Registered:
    29 Jun 2018
    02 Dec 2020 in reply to Daniel van Doorn
    Link to this post
    Hey Daniel,

    Thanks for the info. I will take a look at that.

    I ended up not using the DatasetModel class and just using the TT.
6 posts, 2 answered