Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003

    Question Unanswered: Calling SQL Server stored procedure

    Hi there,

    I would like to execute a stored procedure from SQL Server with one parameter, but I am not sure of the syntax. I am using DBD::ODBC to handle the database.

    My code looks something like this:

    use DBI;
    my $sth = $dbh -> prepare("EXEC spExecuteDTS 'protein'");
    $sth -> execute;

    "protein" is the parameter I am sending. When I try this it complains that no parameter is being supplied.

    Any ideas?


  2. #2
    Join Date
    Jan 2004
    i think you should try it like this
    my $sth = $dbh -> prepare("EXEC spExecuteDTS" & 'protein');
    $sth -> execute;

  3. #3
    Join Date
    Dec 2003
    I've managed to figure out a solution (others may work):

    my $sth = $dbh -> prepare("EXEC text_to_db ?");
    $sth -> execute('protein') or die $dbh -> errstr;
    $sth -> finish;

    Note the "?" in the first line. That apparently tells Perl that a parameter will be sent in the execute call.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts