Options

Delete BLOB data through Reports

nvgnvg Member Posts: 25
Hi there,

I have this big table with images in a field called "Photo" which is a BLOB field.

I want to delete all these pictures from the table and for this I have created a temporary (processing only) report. I am writing the following code in the OnAfterGetRecord trigger of the Table Dataitem:

IF Photo.HASVALUE THEN
BEGIN
CALCFIELDS(Photo);
CLEAR(Photo);
MODIFY;
END;

Somehow this does not seem to work. Anyone with a better suggestion to empty a BLOB field "in one go".

Thanks, NVG

Comments

  • Options
    krikikriki Member, Moderator Posts: 9,090
    When you loop records to change some field in it, it is better to put the record in another buffer and change the field in that buffer.
    IF recMyTable.Photo.HASVALUE THEN
      BEGIN
        recMyTable2 := recMyTable;
        recMyTable2.CALCFIELDS(Photo);
        CLEAR(recMyTable2.Photo);
        recMyTable2.MODIFY;
      END;
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    fbfb Member Posts: 246
    Hmm... ? Perhaps the CALCFIELDS must occur before the HASVALUE test...?
    CALCFIELDS(Photo);
    IF Photo.HASVALUE THEN BEGIN 
      CLEAR(Photo); 
      MODIFY; 
    END;
    
  • Options
    nvgnvg Member Posts: 25
    Dear fb,

    Thanks very much. Putting CALCFIELDS before checking HASVALUE did the trick. Silly ommision on my part.

    Thanks to kriki too for achieving that in another way.

    Regards,
    NVG
Sign In or Register to comment.