KUBO Takehiro
11/11/2007 3:53:00 AM
Hi,
On 11/9/07, Sean Nakasone <seannakasone@yahoo.com> wrote:
> I'm using the OCI8 module to dump out Oracle tables. Some of the fields
> are defined as RAW and the dumped data is in binary format. Is there a
> way to have this dumped as HEX? I wouldn't know which fields would be RAW
> so I'm hoping OCI8 is smart enough to detect RAW fields and convert them
> to HEX automatically.
1. Change oci8.rb as follows.
From: (line 860 - 866)
-----------------------------------
when SQLT_LNG, SQLT_LBI
datasize = @ctx[OCI8::Util::CTX_LONG_READ_LEN]
when SQLT_CLOB
datatype = :nclob if p.attrGet(OCI_ATTR_CHARSET_FORM) == SQLCS_NCHAR
end
-----------------------------------
To: (line 860 - 868)
-----------------------------------
when SQLT_LNG, SQLT_LBI
datasize = @ctx[OCI8::Util::CTX_LONG_READ_LEN]
when SQLT_CLOB
datatype = :nclob if p.attrGet(OCI_ATTR_CHARSET_FORM) == SQLCS_NCHAR
when SQLT_BIN
datasize *= 2 if OCI8::BindType::Mapping[OCI8::SQLT_BIN] ==
OCI8::BindType::String
end
-----------------------------------
2. Add the following code to your code.
OCI8::BindType::Mapping[OCI8::SQLT_BIN] = OCI8::BindType::String
To revert the behavior:
OCI8::BindType::Mapping[OCI8::SQLT_BIN] = OCI8::BindType::RAW