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