Convert a Text to a Blob

KyleaKylea Member Posts: 39
I have 2 fields - 1) CreditCardNo (text 16) & 2) CreditCardNoBlob (Blob).

On Validate for CreditCardNo I want to push the text data to a blob - I understand you can use INSTREAM to do this - but I need help to get it right.

So far I have the following:

Definitions:

StreamInObj = DataType InStream
CreditCardNoProtect = BLOB
CreditCardNo = Text (16)

CreditCardNoProtect.CREATEINSTREAM(StreamInObj);

I am unsure what to do to get Credit Card No into the blob field.

Can someone show me what the code should be with an explanation on each line of how it actually works or what each line is doing. I looked at the example in the help text but not sure how much of it is relevant considering it seems to be writing messages.

Thanks
Kylea

Answers

  • garakgarak Member Posts: 3,263
    Example Send Date from a field or variable (txt1/2 is atextvariable, example use table 27):
    if (txt1 <> '') then begin
      Picture.CREATEOUTSTREAM(StreamOut);
      StreamOut.WRITE(txt1);
      modify;
    end;
    

    Read Data from BLOB and write text in textvariable
    calcfields(Rec.Picture);
    if Rec.Picture.hasvalue then begin
      Rec.Picture.CREATEinSTREAM(Streamin);
      //while not StreamIn.EOS do begin  //if you need somewhat in a loop
        StreamIn.READ(txt2);
      //end;
    end;
    

    Regards
    Do you make it right, it works too!
  • KyleaKylea Member Posts: 39
    edited 2009-01-14
    Thankyou - exactly what I needed :D:D:D

    So now I have my credit card info appearing as * in my blob field - in order to display it on a form I gather I would need to do the reverse to an InStream ie Blob to a text field so the user could see it. Is that correct.


    Kylea
  • garakgarak Member Posts: 3,263
    Please, and welcome

    if you got the answere you can set the attributoption solved (go to the first post, press edit, set the attribute -> optionfield on top)
    Do you make it right, it works too!
  • kanikakanika Member Posts: 247
    thanks guys, this has helped me a lot !!!
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    @kanika please bear in mind that this is a 9 years old thread. A lot has changed since, and if you are on version newer than NAV2009 I'd suggest you to look into the TempBLOB table and use standard ReadAsText / WriteAsText functions available there.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • kanikakanika Member Posts: 247
    edited 2018-06-26
    From what version? I needed it for NAV2009 and it worked ok, but in NAV2015 I can not find any function in that table
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    I'm just saying that in newer versions there are new standard functions handling this.

    If you are on 2009 that's OK then, however you may still want to implement your change as a function in TempBLOB table, just like they are implemented now in post-2009 versions. If you use the same function names it will be a just a tiny bit easier to upgrade your system in the future.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.