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


In reply to Handling/Converting Binary Data Returned via a DBI ODBC Connection by jmurphy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.