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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.