php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16496 Stored Procedure Parameters is_null issue
Submitted: 2002-04-08 11:54 UTC Modified: 2002-12-24 01:00 UTC
From: arthur dot mcgibbon at btinternet dot com Assigned:
Status: No Feedback Package: MSSQL related
PHP Version: 4.1.2 OS: Win2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
25 - 8 = ?
Subscribe to this entry?

 
 [2002-04-08 11:54 UTC] arthur dot mcgibbon at btinternet dot com
The problem is with executing a stored procedure with a null-value varchar output parameter.

Steps...
1) create any SP that has a varchar(200) input/output param
e.g.
create procedure Test
(
  @TestVarchar varchar(200) = null output
)
as
select @TestVarchar = 'Successful parameter feedback';

2) Run stored procedure using following statements...

$ConnectionObj = mssql_connect($DB_SERVER_NAME, $DB_USER, $DB_PASSWORD);
$aStatement = mssql_init("dbo.test", $ConnectionObj);
mssql_bind($aStatement, "RETVAL", &$RetVal, SQLINT4);
mssql_bind($aStatement, "@TestVarchar", &$Value, SQLVARCHAR, TRUE, TRUE, 200);
$ExecResult = mssql_execute($aStatement);

When PHP executes the SP it defines the parameter as VARCHAR(0) when it should be VARCHAR(200).

I've run SQL Profiler and it shows... 
declare @P1 varchar(0)
set @P1=NULL
exec dbo.test @P1 output
select @P1

when it should be
declare @P1 varchar(200)
set @P1=NULL
exec dbo.test @P1 output
select @P1

If you change the bind statement so that the @TestVarchar parameter is not null then the whole thing works.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-07 01:53 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-12-24 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over 2 weeks, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 11:01:28 2024 UTC