db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <rick.hille...@oracle.com>
Subject Re: FW: Clob to Blob
Date Tue, 17 Sep 2013 14:58:47 GMT
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.

> Brett Okken
> -----Original Message-----
> From: Rick Hillegas [mailto:rick.hillegas@oracle.com]
> Sent: Tuesday, September 17, 2013 7:40 AM
> To: derby-user@db.apache.org
> Subject: Re: FW: Clob to Blob
> On 9/16/13 2:23 PM, Virag Kothari wrote:
>> Anyone, Is there a way?
>> From: Virag Kothari<virag@yahoo-inc.com<mailto:virag@yahoo-inc.com>>
>> Date: Friday, September 13, 2013 3:53 PM
>> To: "derby-user@db.apache.org<mailto:derby-user@db.apache.org>"
>> <derby-user@db.apache.org<mailto:derby-user@db.apache.org>>
>> 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.

View raw message