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 12:40:05 GMT
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: 

You may find the following class useful, too. You can clone (and 
improve) this class to write your own BLOB implementation as necessary: 

Hope this helps,

View raw message