Delete BLOB data through Reports

nvg
nvg 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

  • kriki
    kriki Member, Moderator Posts: 9,124
    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!


  • fb
    fb Member Posts: 246
    Hmm... ? Perhaps the CALCFIELDS must occur before the HASVALUE test...?
    CALCFIELDS(Photo);
    IF Photo.HASVALUE THEN BEGIN 
      CLEAR(Photo); 
      MODIFY; 
    END;
    
  • nvg
    nvg 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