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

I have a perl script that calls a stored proc in MSSQL 2008. When I run the script I get this error: MicrosoftODBC SQL Server DriverSQL ServerThe formal parameter "@Username" was not declared as an OUTPUT parameter, but the actual parameter passed in requested output. (SQL-42000) The perl code I use is (I have removed the connection UID and PASS for security):
#!perl -w use strict; use CGI q~:standard~; use DBI; use Digest::MD5 q~md5~; use CGI::Carp q~fatalsToBrowser~; my ($DBH, $STH, $Username, $Password, $Error, $Cookie); $Username = param('Username'); $Password = param('Password'); $Password = md5($Password); $DBH = DBI -> connect ('dbi:ODBC:SQLServer', '', '') or die "$DBI::err +str"; $STH = $DBH -> prepare (qq~exec FinalFantasyInfo.dbo.CheckLogIn ?, \@U +sername = '$Username', \@Password = '$Password'~) or die "DBI::errstr +"; $STH -> bind_param_inout(1, \$Error, 1); $STH -> execute or die "$DBI::errstr"; if ($Error == 1) { print redirect('http://admin.ffinfo.com/login2.html'); } else { $Cookie = new CGI::Cookie (-name => 'FFAdmin0229', -value => ['$Username', '$Password'] ); $Cookie -> bake; print redirect('http://admin.ffinfo.com/portal.html'); }
my stored proc looks like this:
create proc CheckLogIn ( @Username varchar(50), @Password varchar(50), @Error tinyint output ) as if (select COUNT(*) from FinalFantasyInfo.dbo.MainStaffInfo where UID += @Username and Password = @Password) = '1' set @Error = '0' else set @Error = '1'
I have been looking for a while now and just can't see the error, I am sure it is something small and stupid. Can someone give me a second set of eyes and see if they can find it?

Replies are listed 'Best First'.
Re: Need a second set of eyes, can't find the error
by Anonymous Monk on May 02, 2009 at 16:57 UTC
    H -> prepare (qq~exec FinalFantasyInfo.dbo.CheckLogIn ?,
    Arent you missing placeholder(s) (one for username, one for password, one for error?)?
      I don't think I am. I just want to pass the $Username and $password varibles to the SQL statment, I don't want them returned from the statement.
        So why do you have a placeholder (questionmark)?