Hi All, Thank you all for replies. I tried casting in Java by converting clob.getCharacterStream to a binary stream using UTF-8 and it worked.
Regards, virag On 9/17/13 7:58 AM, "Rick Hillegas" <[email protected]> wrote: >On 9/17/13 7:36 AM, Okken,Brett wrote: >> Wouldn't the desired character encoding be a required input when >>translating from a CLOB to a BLOB? >Hi Brett, > >That sounds right. The clobToBlob() routine could take a character >encoding argument or default to some character encoding which makes >sense to the application. The routine might be able to use >Clob.getAsciiStream() in order to unpack the CLOB as a byte stream. > >Thanks, >-Rick >> Brett Okken >> >> -----Original Message----- >> From: Rick Hillegas [mailto:[email protected]] >> Sent: Tuesday, September 17, 2013 7:40 AM >> To: [email protected] >> Subject: Re: FW: Clob to Blob >> >> On 9/16/13 2:23 PM, Virag Kothari wrote: >>> Anyone, Is there a way? >>> >>> From: Virag Kothari<[email protected]<mailto:[email protected]>> >>> Date: Friday, September 13, 2013 3:53 PM >>> To: "[email protected]<mailto:[email protected]>" >>> <[email protected]<mailto:[email protected]>> >>> Subject: Clob to Blob >>> >>> Hi, >>> >>> Is there a way to cast from clob to blob in derby? >>> From the table at >>> http://db.apache.org/derby/docs/10.2/ref/rrefsqlj33562.html, there >>> isn't seem a direct or indirect way to do so. >>> >>> Thanks, >>> Virag >> Hi Virag, >> >> As Knut noted, Derby does not support casts from character to binary >>types. Here Derby follows the casting rules laid out in the SQL >>Standard, part 2, section 6.13 (<cast specification>). However, as Knut >>also noted, you can write your own coercion function, say clobToBlob. >> Then you can write queries like this: >> >> insert into blobTable( blobColumn ) >> select clobToBlob( clobColumn ) from clobTable; >> >> For more information on user-written functions, please see the >>following topic in the Derby Reference Guide: >> >>http://db.apache.org/derby/docs/10.10/ref/rrefcreatefunctionstatement.htm >>l >> >> You may find the following class useful, too. You can clone (and >> improve) this class to write your own BLOB implementation as necessary: >> org.apache.derby.iapi.types.HarmonySerialBlob >> >> Hope this helps, >> -Rick >> >> >> CONFIDENTIALITY NOTICE This message and any included attachments are >>from Cerner Corporation and are intended only for the addressee. The >>information contained in this message is confidential and may constitute >>inside or non-public information under international, federal, or state >>securities laws. Unauthorized forwarding, printing, copying, >>distribution, or use of such information is strictly prohibited and may >>be unlawful. If you are not the addressee, please promptly delete this >>message and notify the sender of the delivery error by e-mail or you may >>call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) >>(816)221-1024. >> >
