Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binary Large Object manipulation/General Fields

Status
Not open for further replies.

cmergal

MIS
Oct 16, 2002
18
US
Hello all:

I have a table in Informix that has a BLOB column that contains PDF files in it. When I connect to it the field comes as general but when I try to view it (CTRL+PgDn) a message comes up saying that the "OLE object is invalid or corrupted". I verified the data and it is valid.

I am using SQLEXEC to extract the data. How do I extract this data so I can manipulate it?

TIA,

Carlos
 
Carlos,
You might try something like:
Code:
lcString = mytable.mygenfield
lcFileName = "mytemp.pdf"
=StrToFile(lcString, lcFileName)

declare INTEGER ShellExecute in shell32 INTEGER handle, STRING @ oper, ;
   STRING @ ifile, STRING @ iparam, STRING @ ipath, INTEGER showcmd
=shellexecute(0,"open",lcFileName,"","c:\",1)
Rick
 
Rick;

Its a great idea but the first part the lcString=mytable.mygenfield comes with an error saying the operation is invalid for a general field....

...So back to the drawing board!

Carlos
 
I couldn't find that particular "utility" now (things do get added and removed over time!), but I did find this message sequence:
*------
Hi All,
I have BMP's in a general field in an app, and I would like to extract them to BMP's. I'm running VFP 7. How can I go about doing this?

Thanks.

Daniel (Johnson)
*------
You should be ablt to figure this one out....
Code:
SELECT pictures
* Make sure the created file contains this picture only!
COPY TO &lcdbf FIELDS &pcfield &pnfor && for upper(&pcField)=upper(pcPict)
lnhandle=FOPEN(lcfile + '.fpt')
lnhandleout=FCREATE(lcfile + '.bmp')
=FSEEK(lnhandle, 599)
DO WHILE !FEOF(lnhandle)
 =FWRITE(lnhandleout, FREAD(lnhandle, 512), 512)
ENDDO
=FCLOSE(lnhandle)
=FCLOSE(lnhandleout)
Ranjan Brahma
*------

Another variant is by Çetin Basöz:
Code:
Function savebmps
Lparameters tcTable, tcField, tnRecNo, tcOutFileName
* tcTable - Tablename containing BMP gen field
* tcField - Gen field name
* tnRecNo - recno no extract
* tcOutFileName - path and fielname of output filename

Local handle, handleout, lcTable
lcTable = "T"+Sys(2015)
Select &tcField From (tcTable) ;
  where Recno() = tnRecNo ;
  into Table (lcTable)
Use
handle=Fopen(lcTable+".fpt")
handleout=Fcreate(tcOutFileName)
lnSize = Fseek(handle, 0, 2) && Seek to eof and get size
=Fseek(handle,599)           && Go to start of gen file
If ( lnSize - 599 ) % 2 = 0  && Might it be a duplicate ? Let's check
  lcFirst = Fread(handle, (lnSize - 599)/2) && Read first part to lcFirst
  lcSecond = Fread(handle, lnSize) && Read rest to lcSecond
&& lnSize is totlen
&& but fread() would stop at feof()
  =Fwrite(handleout, lcFirst, lnSize) && Again lnSize is bigger but
&& correct size would be written
  If lcFirst # lcSecond   && It was not a duplicate, so write lcSecond too
    =Fwrite(handleout, lcSecond, lnSize)
  Endif
Else
  =Fwrite(handleout, ;
    fread(handle,lnSize), ;
    lnSize)                 && Since now we have a size at hand.
&& So let's do readwrite in one pass
Endif
=Fclose(handle)
=Fclose(handleout)
Erase (lcTable+".*")
Cetin
*------

Rick
 
Thanks!

But, I'm sort of in need of a more generic approach, one that can handle a number of file types. I saw something from another thread about the ghostscript approach, but, I still haven't found out if that's can solve my problem. I'm still waiting for the reply from that thread...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top