Why does an output parameter has to be initialized?

Discussion Why does an output parameter has to be initialized?

  • 29 Maret 2012 13:18
     
     

    Hi,

    at the moment we are still using PHP 5.2 and therefore we have to use the driver version 2.0. I don't know if the problem still appears in version 3.0.

    I have a stored procedure with an output parameter that returns an uniqueidentifier. Therefore I have to initialize the parameter with a random GUID first. That doesn't make sense to me.

    The matter with an output parameter is that I don't have any value for that parameter until I execute the stored procedure.  

    In September 2010 you mentioned in another thread that this problem is a design limitation. Is there a chance to be fixed soon?

    Thanks,

    Michael



    • Diedit oleh eMicify 29 Maret 2012 13:20
    •  

Semua Balasan

  • 03 April 2012 17:40
     
     

    Hi eMicify,

    We need a bit more information about the problem you are highlighting. Is your GUID being returned as a string?

    Thanks,

    Jonathan


    This posting is provided 'AS IS' with no warranties, and confers no rights.

  • 03 April 2012 19:14
     
     

    I don't think that's it Jonathan, Michael is complaining about initialising output parameters in stored procs, and wonders whether it has been fixed yet. 

    In the past, an output string variable had to be pre-initialised, or the maximum length had to be passed as part of the parameter.  PHP variables are supposed to be magic.  The thread he links to (http://social.msdn.microsoft.com/Forums/en/sqldriverforphp/thread/ff1ee363-4d33-4eb9-b43b-9e1ec5a9339d) contains comments from a few other dissenters (me included)


    Rob

  • 04 April 2012 0:15
     
     

    I don't think that's it Jonathan, Michael is complaining about initialising output parameters in stored procs, and wonders whether it has been fixed yet. 

    In the past, an output string variable had to be pre-initialised, or the maximum length had to be passed as part of the parameter.  PHP variables are supposed to be magic.  The thread he links to (http://social.msdn.microsoft.com/Forums/en/sqldriverforphp/thread/ff1ee363-4d33-4eb9-b43b-9e1ec5a9339d) contains comments from a few other dissenters (me included)


    Rob

    Ok, to clarify, the issue you are reporting is that output parameters which are not strings are not getting the amount of memory allocated to fit the incoming data from the server. It has nothing to do with whether it's a Stored Proc, or not? :)

    Cheers,

    Jonathan


    This posting is provided 'AS IS' with no warranties, and confers no rights.

  • 04 April 2012 7:37
     
     

    I don't think that's it Jonathan, Michael is complaining about initialising output parameters in stored procs, and wonders whether it has been fixed yet. 

    In the past, an output string variable had to be pre-initialised, or the maximum length had to be passed as part of the parameter.  PHP variables are supposed to be magic.  The thread he links to (http://social.msdn.microsoft.com/Forums/en/sqldriverforphp/thread/ff1ee363-4d33-4eb9-b43b-9e1ec5a9339d) contains comments from a few other dissenters (me included)


    Rob

    That's what I meant.

    If I don't initialize the output parameter, I receive the following error: "An invalid PHP type was specified as an output parameter. DateTime objects, NULL values, and streams cannot be specified as output parameters."

  • 04 April 2012 11:05
     
     

    Jonathan - isn't it *only* stored procs that can have output parameters?


    Rob

  • 04 April 2012 18:07
     
     

    Jonathan - isn't it *only* stored procs that can have output parameters?


    Rob

    My bad, you're right and that's the case generally (CLR and C++ SPs can also do it, but few people use these). We're investigating this issue, we'll see what's going on.

    Cheers,

    Jonathan


    This posting is provided 'AS IS' with no warranties, and confers no rights.