How to find if BLOB field is empty.

Posted by OctavioOlguin on 31-Jul-2015 11:55

I wonder, does a BLOB empty exist?  or is just a blob with null content?

for my purposes, I need to know if I already have stored something on a blob, otherwise, call a routine to fill blob field.

When I compare: table.blob-field <> ?  is returning no, but whe I COPY-LOB FROM table.blob-field TO FILE "C:\temp\2.pdf".

I got an empty 2.pdf file.

What am I missing?

TIA

Jorge Octavio

All Replies

Posted by TheMadDBA on 31-Jul-2015 12:10

I guess I am confused by your question.... <> ? returns no when the field is actually ?.

Run this to see the different values:

display length(table.blob-field) (table.blob-field = ?) (table.blob-field <> ?).

Posted by OctavioOlguin on 31-Jul-2015 12:29

Thanks.

I got, respectivelly

?  yes  no

SO i guees the way to tell if a blob is empty is "length(b) = ?"    , what you thin?

Posted by TheMadDBA on 31-Jul-2015 12:42

Any of those approaches work as long as you react appropriately to the answer.

if ( length(b) > 0)  = TRUE then outputpdf.  /* false for ? or 0 */

if (b <> ?) = TRUE then outputpdf. /* false when it is ? */

if (b = ? ) = FALSE then outputpdf. /* true when it is ? */

I suppose LENGTH(blob-field) > 0 may be the "safest" .

Posted by George Potemkin on 01-Aug-2015 13:16

LENGTH(blob-field) will force Progress to read BLOB from disk.

Of course, it's not a problem if you're going to read it anyway. But when you just need to know if the field is empty or not then (table.blob-field ne ?) is, IMHO, a better solution.

Regards,

George

This thread is closed