Wouldn't the desired character encoding be a required input when translating 
from a CLOB to a BLOB?

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.html

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.

Reply via email to