I have multiple stored procedures stored in a MS SQL database. I have my connection setup fine, but having problems passing variables into it. Here is my sp call:
#execute stored procedure my $sp = $msdbh->prepare(qq|usp_Dashboard_CallType \@start = 20080101| +); $sp->execute or die("$sp->errstr");
It doesn't like the date I am passing shown here:
DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver][SQL +Server]Error converting data type int to datetime.
I have two questions about this: 1) How can I pass the variables properly in the format the SQL server wants, and 2) I need to execute this stored procedure for every date starting from the beginning of the year up until yesterday. I am assuming I need to loop through the an array somehow, maybe put this and the other stored procedure executions I need to do into a subroutine and pass each date one by one to the sub, while converting it properly to the SQL datetime? I am also looking into the fact there may be a problem with what the SQL server is doing as far as conversion. But regardless, Is this correct if I want to loop thru dates in a subroutine?
my $sp = $msdbh->prepare(qq|usp_Dashboard_CallType \@start = $next_dat +e|);

In reply to DBI::ODBC Stored Procedure execution by hallikpapa

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.