Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Handling/Converting Binary Data Returned via a DBI ODBC Connection

by jmurphy (Acolyte)
on Jun 28, 2002 at 22:19 UTC ( [id://178171]=perlquestion: print w/replies, xml ) Need Help??

jmurphy has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I working with an application that stores the body of an e-mail within the "text" column (which is a binary datatype) of a SQL Server database table.

I'm using Matt's XML::Generator::DBI module and the DBD::ODBC driver to connect to the datasource. According to Matt's documentation he encodes binary data as Base64.

I need to convert this binary date (now Base64) back into the original e-mail message however, I'm not quite sure how to tackle the problem. Can anybody offer any help?

Here's a code sample showing how I connect to the datasource:

# Instantiate a handle to the database. use DBI; my $dbh = DBI->connect("dbi:ODBC:$opt_hash{dsn}", $opt_hash{user}, $op +t_hash{pass}, {LongTruncOk => 1}) or die "Couldn't open database : '$DBI::errstr'; stopped"; # Instantiate the generator. use XML::Generator::DBI; my $generator = XML::Generator::DBI->new(RowElement => "Message", Hand +ler => $builder, dbh => $dbh); # Obtain a reference to the DOM. my $dom = $generator->execute("exec $opt_hash{sp} \'$opt_dates{start}\ +', \'$opt_dates{end}\'"); # Print the result print $dom->toString;
The XML output looks as follows:
<Message> <ID>157</ID> <createdate>2002-05-21 09:39:16.343</createdate> <Subject>Msg4</Subject> <MessageBody>LCBJIGFtIHN0aWxsIHVuYWJ</MessageBody> </Message>
Thanks, Jay

Replies are listed 'Best First'.
Re: Handling/Converting Binary Data Returned via a DBI ODBC Connection
by kvale (Monsignor) on Jun 28, 2002 at 22:33 UTC
      Thanks so much.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://178171]
Approved by dws
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-03-29 15:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found