Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm using Perl v5.6.1 built for MSWin32. I am calling a MS SQL Server stored procedure through ODBC. How can I get the results of an output parameter in Perl? I created this stored procedure:
CREATE PROC sp_proc1 @param int OUTPUT AS SELECT @param = 1 RETURN 0
and called it from perl like this
my $param = 0; $sql_obj->sql("EXEC sp_proc1 \@param = '$param' OUTPUT");
I get this error:
"Cannot use the OUTPUT option when passing a constant to a stored procedure."

I understand why I get the error. Is there any way I can pass a variable so I get the value in the OUTPUT parameter in Perl? Is it even possible?

Much thanks if you can help me out.

Edit by dws to add tags

Replies are listed 'Best First'.
Re: stored proc output params
by rdfield (Priest) on Nov 16, 2002 at 15:40 UTC
    If you're using DBD::ODBC then use placeholders and bind_param. See the docs for details.

    rdfield

      Thanks for the reply. I can't find any documentation on that. Can you post an example or a link to the doc?
        DBI, specifically bind_param_inout in "DBI STATEMENT HANDLE OBJECTS".

        rdfield