Good Day and Thank You for taking the time to share your wisdom!

I have searched for an answer to my question to no avail.

My dilemma:
When attempting to execute a query against an MS SQL server, it returns undef. When I execute the query from a cmd prompt, it returns a row. This is Strawberry Perl on a Windows machine.

The query does not seem to use the % in the LIKE no matter how I phrase it. Are there other options? Am I missing something?

My code:

## Prepare the Select Handle for the Transaction Code in the Descripti +on field my $select_TransactionCode_handle = $db_handle->prepare( qq{ SELECT [Code] FROM [Transaction Code] WHERE [Description] LIKE ? } ); $select_TransactionCode_handle->execute( $transactionCodeQuery . '%' ) +; # THIS DID NOT WORK # $select_TransactionCode_handle->bind_param( 1, $transactionCodeQuery + . '%' ); # THIS ALSO DID NOT WORK # $select_TransactionCode_handle->execute; # $select_TransactionCode_handle->bind_param( 1, $transactionCodeQuery + ); # THIS ALSO DID NOT WORK # $select_TransactionCode_handle->execute( '%' ); ## Grab the Transaction Code if it already exists my @transactionCodes = $select_TransactionCode_handle->fetchrow_array; + # THIS RETURNS undef

The information returned includes this: "$select_TransactionCode_handle->{$transactionCodeQuery.'*'} = undef;". I do not know where the '*' is coming from.

I am hoping I have missed something simple. :-)

Thank You in Advance! Please let me know if you need more information! Thanks for your time!

glenn

In reply to Perl DBI query of MS SQL with LIKE by gcasa

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.