retrieving blobs

cjaymcmeans

Well-known member
Joined
Jan 12, 2005
Messages
85
Programming Experience
3-5
i recently posted a thread about saving documents and pdf's in the database...
i have solved that problem as far as documents are concerned anyway(pdf's are still a big mystery to me)..
saving was literally a very grueling task..
now my problem is retrieving the data that i saved... and placing it in a directory so that the user can access it and save it at will...
hope theres some one out there that can help...


thanks...
 
im using DB2 as backend...
i had to create a batch file to process the insertion through the command line window.
 
I dont know how to read clobs from db2. In oracle we pass chunks of 32kilobytes through a streamreader, or something like that.. Google for how to retrieve db2 clobs..
 
I cant give you any code, sorry.. it's highly confidential. Any other app, wouldnt be a problem, but this app is both the only one we use with clobs and the only one where the source is protected.. :/
 
darn... i found a clob code from the ibm website..
its ok... but the thing is it just lets me view the file as string...
so all i could do was load it in a textbox and browse through it..
although one can edit it.. it only covers the text part of the document...
so charts, tables and the likes are totally out of the question...
anyways..
thanks..
 
well, we use a stored procedure to repeatedly read or write the clobs.. ie.e a sproc takes a clob and an ID for writing..
the first write, the ID is determined by the db. every call of APpendCLob sproc thereafter appends the 32kb uploaded, to the database clob.
For reading, a ReadClob, taking a parameter number of which 32kb chunk to read, is used.. so a write op for 100kb of clob might look like:

InsertClob(ID, clob chunk 1) '32
AppendClob(ID, clob chunk 2) '64
AppendClob(ID, clob chunk 2) '96
AppendClob(ID, clob chunk 2) '4

And a read might be:

ReadClob(ID, clob, 1) 'first 32k
ReadClob(ID, clob, 2) 'second 32k
ReadClob(ID, clob, 3) 'third 32k
ReadClob(ID, clob, 4) 'last 4k


concat on the client, and do whatever with ti. its xml so we show it in a browser, actually by writing it to disk and then navigatin to the file.. Sounds lame, but web browser isnt really flexible to do it another way..



but if you found a resource that lets you get the whole clob, what is the problem?
 
i have successfully saved the clob... retrieval is the problem...
i used the commandline to insert it in the database..
but when you try retrieving it. well the bottomline is i really have no clue how to retirve it properly..
so i tried using a select statement and getting the byte size then writing it in a file..
didnt work :( all i got were ascii characters...
then the other approach i was talking about
saves the clob in .net
again retrieval is a real pain...
once you've selected it.. you have to treat it as string.
well thats what the code says..
you put it in a text box for viewing and updates...
but as i've mentioned its limited to text only...
as for other document properties well i dont think it can be accomodated.
 
but as i've mentioned its limited to text only...
as for other document properties well i dont think it can be accomodated.

CLOB = character large object

thus, that it is limited to text only, is expected. If you wish to store binary, use a BLOB
 
cjard... thanks for the lengthy discussion...
it really helped me.. i got to save pdf's and documents...
i used a different approach though in retrieval...
unlike the one you mentioned...
i did not make any installments... i directly wrote the data into the file...
also..
as you suggested i used blobs..
it was my bad...
my officemate insisted that i use clobs... i kinda got talked into it...
again
thanks..
 
no probs.. i actually confused myself revisiting this thread because you said blobs in the subject, but then we both talked about clobs... :D
 
Back
Top