Hi any one can explain below Subroutine. original subroutine has only one argument but i need to pass two argument to below stored procedure. original way of calling Sub is ExecStoredProcedureArg1("pr_CustomForPV", $AutoNumber, "IsCustom") I have changed the sub to like ExecStoredProcedureArg1("pr_CustomForPV", "$VersionID,$AutoNumber", "IsCustom"). it is still working fine. my question is how the sub is working with two parameters and please explain subroutine what is qq.what is fetch row? what i need to learn to understand this subroutine.

if (0 != ExecStoredProcedureArg1("pr_CustomForPV", "$VersionID,$AutoN +umber", "IsCustom")) { # Do some thing } sub ExecStoredProcedureArg1($$$) { writelog(info,"Entering ExecStoredProcedureArg1() : ===="); my ($strStoredProc,$strArg, $strResultField) = @_; my $strResultValue = ""; my $mydb = Win32::ODBC->new($DSN); if (!$mydb) { Win32::ODBC::DumpError(); writelog(logdie,"Failed to connect to $DB_SERVER!"); } my $sql = qq|$strStoredProc $strArg|; if ($mydb->Sql($sql)) { Win32::ODBC::DumpError(); } if ($mydb->FetchRow()) { %DataSet = $mydb->DataHash(); $strResultValue = $DataSet{$strResultField}; } else { writelog(info,"No row found for $strResultField"); $mydb->Close(); } $mydb->Close(); writelog(info,"$strStoredProc $strArg for $strResultField: value += $strResultValue"); writelog(info,"Exiting ExecStoredProcedureArg1() : ===="); return $strResultValue; }
stored procedure: In the below procedure i have added @number parameter.original stored procedure has only one parameter
CREATE PROCEDURE dbo.pr_CustomForPV ( @VersionID int, @Number int ) AS SELECT CASE WHEN U.SourceFileName IS NOT NULL Then 1 ELSE 0 END AS IsCustom # some joins

In reply to Calling Stored procedure from perl by mtrasp

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.