12.07.2015 Views

DB2 data manipulation

DB2 data manipulation

DB2 data manipulation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

developerWorks®ibm.com/developerWorksThe input stream is used to store the retrieved BLOB in a file calledclonedredbookcover.jpg. To retrieve CLOBs, much of the syntax is similar to that ofretrieving a BLOB.FILE FILEOUTPUT = ;NEW;FILE("C:\\CLONEDREDBOOKABSTRACT.TXT");FILEOUTPUTSTREAM FO = ;NEW; FILEOUTPUTSTREAM(FILEOUTPUT);INPUTSTREAM IS = CLOB.GETASCIISTREAM();INT C;WHILE; ((C = IS.READ()) != -1)FO.WRITE(C);FO.CLOSE();In the Java snippet above, the stored CLOB was materialized to a new file namedclonedredbookabstract.txt. This is done by using the getAsciiStream method of theCLOB. Just like you did when retrieving the BLOB, you assign the stream to anInputStream, which then is read from, and in turn write what was read to theFileOutputStream.Section 9. ConclusionSummaryIn this tutorial, you learned many concepts on <strong>data</strong> <strong>manipulation</strong> strategies. Youlearned how to:• Access the <strong>data</strong> in multiple tables and change them• Use MQTs• Use SQL routines• Use common tables• Use cursors• Use CLOB and BLOB <strong>data</strong> types• Program with transactionsWhile this tutorial focused on concepts, further tutorials in this series describe all theinterfaces used to perform <strong>data</strong> <strong>manipulation</strong>.<strong>DB2</strong> <strong>data</strong> <strong>manipulation</strong>Page 22 of 25© Copyright IBM Corporation 1994, 2007. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!