From: Tomas H. <kvi...@se...> - 2005-08-25 10:55:31
|
I have a problem retrieving BLOBs from Oracle. The trouble is that the oracle module returns LOBs as zero terminated strings (at the low level). The BLOB is truncated if it contains zero byte. Have anybody come across this problem? Sample code: (oracle:run-sql "select id, doc from tab" (oracle:do-rows (id doc) (princ (type-of doc)) ;; THE PROBLEM IS HERE ALREADY (with-open-file (stream (format nil "~a/~a.pdf" dir id) :direction :output :if-exists :supersede :element-type '(unsigned-byte 8)) (write-byte-sequence (convert-string-to-bytes (coerce doc 'string) CUSTOM:*FOREIGN-ENCODING*) stream)))) I can think of some solutions to this: 1) Return BLOBs as byte array: needs to change oracle module both in C and Lisp:-( Might be a lot of work especially when I'm not familiar with low level details of CLisp. This would be ideal solution. 2) Retrieve BLOBs as text, e.g. "select id, doc, utl_encode.base64_encode(doc) as txt from tab". However, this works for short BLOBs only (about 2kB?). Any ideas? Thanks a lot, Tomas |