in reply to how to call stored procedure from ms sql

Can't call method "bind_param" on an undefined value

The important information here is that $sth is undefined when you try to call bind_param on it. That happens when prepare fails. If you check prepare for errors, you'll get some more useful information:

$sth = $dbh->prepare( $sql ) or die $dbh->errstr;

You can wrap that in an eval block if you want, too.

Replies are listed 'Best First'.
Re^2: how to call stored procedure from ms sql
by ephemeralz (Initiate) on Apr 25, 2005 at 23:36 UTC
    is that the correct syntax to call the stored procedure and passing parameters? after doing some research, there seems to be so many ways to do this and i tried every ways and none work.

      A few questions for you:

      1. can you call the stored procedure from your database shell? (I have no idea what mssql stored procedures should look like, but it's the first thing to try, because if it won't work from your database directly, it's not going to work from a Perl script).
      2. what is the error message that was in the database's error string, that friedo suggested you take a look at? (There might be someone on here who can read minds, but it's sure not me)
      3. could you ennumerate those 'every ways' that you've tried, and what the error messages were from them?
      4. could you give more information about the script, such as which DBD you're using?
        1. the ms sql stored procedure is posted in my comment. it does work. 2. there's no error at the prepare statement, the error is at Database error: Can't call method "bind_param" on an undefined value 3. ways tried: $sql = q{ BEGIN :rv := sp_updateStorageSystem(parameter1_in => ?, parameter2_in => ? ); END; }; a) $sth = $dbh->prepare( $sql ) or die $dbh->errstr; b) $sth = $dbh->prepare( "exec sp_updateStorageSystem" ) or die $dbh->errstr; c) $sth = $dbh->prepare( "begin sp_updateStorageSystem end;" ) or die $dbh->errstr; 4. using dbd::odbc how does bind_param works?