Dear brothers in Perl, I have now tried to tackle this problem for quite a while by myself without any success - time to request some of your wisdom!

I am on a Windows box, trying to access through ODBC / Perl DBI/DBD a database that has a table containing a column having the "XML" data type, and I just can't figure out a way to access this data in a bare select query: as soon as my query includes the XML-typed column, the query does not return any row.

The XML-typed column's name is "XmlResults".

The funny thing is 2) returns the expected rows perfectly well when I run the query through my database querying IDE (SqlDbx), connecting to SQL Server the exact same way (using the same ODBC DSN).

Note that no specific error is thrown - it's just that I get 0 row returned.

I have tried using other accessors than the CONVERT statement, XQuery for example, like

SELECT XmlResults.value('/whatever[1]','varchar(50)'), etc.

but I get the same behaviour: works from the IDE, but not from my Perl code :(

My code is quite standard:

my $sth = $dbh->prepare($sql); my @row = $sth->fetchrow_array;

I have tried using $sth->fetchall_arrayref rather than $sth->fetchrow_array but it made no difference.

I have the latest CPAN modules installed.

What would you do to resolve my issue? Any hint/advice on how to analyse the issue further?

Thanks!


In reply to [Windows / SQL Server / ODBC / DBI / DBD] How to access XML data type columns by gaggio

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.