In article <199h8R-1dU-00 / mail.jiubao.org>,
KUBO Takehiro <kubo / jiubao.org> wrote:
> http://www.jiubao.org/ruby-oci8/ruby-oci8-0.1.3.tar.gz
Apart from changing two ¥µ into ¥©'¥µ at line 106 of oraconf.rb, compiles
and installs fine.
Now, when I try to read a BLOB -- inserted in the DB by another program --
I get uninitialized BLOB ¥µ (see below).
Any idea?
-=-=-
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Return pathname of the logo
#
def get_logo
bytes = 0
req = <<-"EOR"
select l_name_logo, mime_type, object_size, object from acb_logo
where id_activity=:1
EOR
loc = nil
begin
sth = $dbh.prepare(req)
sth.execute(@id_activity)
row = sth.fetch
loc = row[:OBJECT]
raw_logo = loc.read # XXX this give uninitialized BLOB
rescue DBI::DatabaseError => err
$stderr.puts "Error: #{err.errstr}"
$dbh.disconnect
exit 2
rescue RuntimeError => msg
$stderr.puts "Error: #{msg}"
$dbh.disconnect
exit 3
end
# Generate an external image file <id_activity>.<ext>
# where <ext> depends on the stored Content-Type.
#
fname = @id_activity.to_s
case row[:MIME_TYPE].to_s
when /jpeg/
fname += ".jpeg"
when /gif/
fname += ".gif"
when /png/
fname += ".png"
else
fname += ".gif"
end
full = row[:OBJECT_SIZE].to_i
begin
if File.exist?(LOGO_PATH) then
if not File.directory?(LOGO_PATH)
raise TypeError
end
else
File.mkdir(LOGO_PATH)
end
File.open(LOGO_PATH + "/" + fname, "w+") do |ofile|
bytes = ofile.write(raw_logo)
end
raise IOError if bytes != full
rescue => msg
$stderr.puts("Error I/O: #{msg}: #{bytes} written out of #{full}")
$dbh.disconnect
exit 3
end
return fname
end # get_logo
-=-=-
--
Ollivier ROBERT -=- Eurocontrol EEC/AMI -=- roberto / eurocontrol.fr
Usenet Canal Historique FreeBSD: The Power to Serve!