Professional Web Applications Themes

#24595 [Opn->Fbk]: Cannot bind output variables. - PHP Development

ID: 24595 Updated by: [email]sniperphp.net[/email] Reported By: hans at velum dot net -Status: Open +Status: Feedback Bug Type: MSSQL related Operating System: Windows XP PHP Version: 5.0.0b1 (beta1) New Comment: Does this happen with PHP 4.3.2 ? Previous Comments: ------------------------------------------------------------------------ [2003-07-10 12:35:09] hans at velum dot net Description: ------------ When using mssql_bind() to bind an output variable, the variable is passed into the stored procedure but the modified value is not returned. (The variable is being passed by reference to mssql_bind()). Reproduce code: --------------- I used the following user-contributed example from mssql_execute manual page. if we have this procedure: CREATE ...

  1. #1

    Default #24595 [Opn->Fbk]: Cannot bind output variables.

    ID: 24595
    Updated by: [email]sniperphp.net[/email]
    Reported By: hans at velum dot net
    -Status: Open
    +Status: Feedback
    Bug Type: MSSQL related
    Operating System: Windows XP
    PHP Version: 5.0.0b1 (beta1)
    New Comment:

    Does this happen with PHP 4.3.2 ?



    Previous Comments:
    ------------------------------------------------------------------------

    [2003-07-10 12:35:09] hans at velum dot net

    Description:
    ------------
    When using mssql_bind() to bind an output variable, the variable is
    passed into the stored procedure but the modified value is not
    returned. (The variable is being passed by reference to mssql_bind()).

    Reproduce code:
    ---------------
    I used the following user-contributed example from mssql_execute manual
    page.


    if we have this procedure:

    CREATE PROCEDURE [procedure]
    (
    sval varchar(50) OUTPUT,
    intval int OUTPUT,
    floatval decimal(6,4) OUTPUT
    ) AS

    if intval is null
    select 'intval is null' as answer
    else
    select 'intval is NOT null' as answer

    set sval='Hello ' + sval
    set intval=intval+1
    set floatval=floatval+1

    return 10

    We can use this PHP code:

    <?php

    $conn=mssql_connect("myhost","user","pwd");

    if ($conn) {
    mssql_select_db("mydb",$conn);

    $stmt=mssql_init("procedure",$conn);
    mssql_bind($stmt,"RETVAL",&$val,SQLINT4);

    $ival=11;
    $fval=2.1416;
    $sval="Frank";

    mssql_bind($stmt,"sval",&$sval,SQLVARCHAR,TRUE);
    mssql_bind($stmt,"intval",&$ival,SQLINT4,TRUE);
    mssql_bind($stmt,"floatval",&$fval,SQLFLT8,TRUE);

    $result=mssql_execute($stmt);

    $arr=mssql_fetch_row($result);
    print ("Answer: " . $arr[0] . "
    " );
    print ("RETVAL = $val ; intval = $ival ; floatval = $fval ; string =
    $sval");

    mssql_close($conn);
    }
    else print("ooops!");


    Expected result:
    ----------------
    Answer: intval is NOT nullRETVAL = 10 ; intval = 12 ; floatval =
    3.1416 ; string = Hello Frank

    Actual result:
    --------------
    Answer: intval is NOT nullRETVAL = 0 ; intval = 11 ; floatval = 2.1416
    ; string = Frank


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=24595&edit=1[/url]

    sniper@php.net Guest

  2. #2

    Default #24595 [Opn->Fbk]: Cannot bind output variables.

    ID: 24595
    Updated by: [email]sniperphp.net[/email]
    Reported By: hans at velum dot net
    -Status: Open
    +Status: Feedback
    Bug Type: MSSQL related
    Operating System: Windows XP
    PHP Version: 5.0.0b1 (beta1)
    New Comment:

    Please try using this CVS snapshot:

    [url]http://snaps.php.net/php4-STABLE-latest.tar.gz[/url]

    For Windows:

    [url]http://snaps.php.net/win32/php4-win32-STABLE-latest.zip[/url]

    and also read the comments in bug #21089



    Previous Comments:
    ------------------------------------------------------------------------

    [2003-08-05 13:31:56] brian_caughlin at hotmail dot com

    By the way, it looks like this bug may be a duplicate of Bug #21089.
    Perhaps this is simply an undoented change.

    ------------------------------------------------------------------------

    [2003-08-05 12:20:15] brian_caughlin at hotmail dot com

    I ran into this issue myself in 4.3.2, and found that the workaround is
    to use the mssql_next_result() function before attempting to access the
    retval and any output parameters. I also found that I don't need to
    pass the variables by reference.

    Here is the code that works for me in 4.3.2:

    <?php

    $conn=mssql_connect("myhost","user","pwd");

    if ($conn) {
    mssql_select_db("mydb",$conn);

    $stmt=mssql_init("procedure",$conn);
    mssql_bind($stmt,"RETVAL",$val,SQLINT4);

    $ival=11;
    $fval=2.1416;
    $sval="Frank";

    mssql_bind($stmt,"sval",$sval,SQLVARCHAR,TRUE);
    mssql_bind($stmt,"intval",$ival,SQLINT4,TRUE);
    mssql_bind($stmt,"floatval",$fval,SQLFLT8,TRUE);

    $result=mssql_execute($stmt);

    $arr=mssql_fetch_row($result);
    print ("Answer: " . $arr[0] . "
    " );
    mssql_next_result($result);
    print ("RETVAL = $val ; intval = $ival ; floatval = $fval ; string =
    $sval");

    mssql_close($conn);
    }
    else print("ooops!");
    ?>

    I hope this helps!

    ------------------------------------------------------------------------

    [2003-07-10 14:38:29] hans at velum dot net

    Yes, I verified that this is also happening with 4.3.2. I thought,
    based on a comment in the manual, that this was not an issue in the
    4.3.2 release.

    I also verified that the bound values are making it *into* the stored
    procedure w/o incident. (E.g. I can add them to the returned result
    row to see that the stored procedure is aware of the values.)

    ------------------------------------------------------------------------

    [2003-07-10 12:52:15] [email]sniperphp.net[/email]

    Does this happen with PHP 4.3.2 ?


    ------------------------------------------------------------------------

    [2003-07-10 12:35:09] hans at velum dot net

    Description:
    ------------
    When using mssql_bind() to bind an output variable, the variable is
    passed into the stored procedure but the modified value is not
    returned. (The variable is being passed by reference to mssql_bind()).

    Reproduce code:
    ---------------
    I used the following user-contributed example from mssql_execute manual
    page.


    if we have this procedure:

    CREATE PROCEDURE [procedure]
    (
    sval varchar(50) OUTPUT,
    intval int OUTPUT,
    floatval decimal(6,4) OUTPUT
    ) AS

    if intval is null
    select 'intval is null' as answer
    else
    select 'intval is NOT null' as answer

    set sval='Hello ' + sval
    set intval=intval+1
    set floatval=floatval+1

    return 10

    We can use this PHP code:

    <?php

    $conn=mssql_connect("myhost","user","pwd");

    if ($conn) {
    mssql_select_db("mydb",$conn);

    $stmt=mssql_init("procedure",$conn);
    mssql_bind($stmt,"RETVAL",&$val,SQLINT4);

    $ival=11;
    $fval=2.1416;
    $sval="Frank";

    mssql_bind($stmt,"sval",&$sval,SQLVARCHAR,TRUE);
    mssql_bind($stmt,"intval",&$ival,SQLINT4,TRUE);
    mssql_bind($stmt,"floatval",&$fval,SQLFLT8,TRUE);

    $result=mssql_execute($stmt);

    $arr=mssql_fetch_row($result);
    print ("Answer: " . $arr[0] . "
    " );
    print ("RETVAL = $val ; intval = $ival ; floatval = $fval ; string =
    $sval");

    mssql_close($conn);
    }
    else print("ooops!");


    Expected result:
    ----------------
    Answer: intval is NOT nullRETVAL = 10 ; intval = 12 ; floatval =
    3.1416 ; string = Hello Frank

    Actual result:
    --------------
    Answer: intval is NOT nullRETVAL = 0 ; intval = 11 ; floatval = 2.1416
    ; string = Frank


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=24595&edit=1[/url]

    sniper@php.net Guest

Similar Threads

  1. #24595 [Fbk->Bgs]: Cannot bind output variables.
    By sniper@php.net in forum PHP Development
    Replies: 0
    Last Post: August 6th, 04:14 PM
  2. #24595 [Com]: Cannot bind output variables.
    By brian_caughlin at hotmail dot com in forum PHP Development
    Replies: 1
    Last Post: August 5th, 06:31 PM
  3. #24595 [NEW]: Cannot bind output variables.
    By hans at velum dot net in forum PHP Development
    Replies: 0
    Last Post: July 10th, 05:35 PM
  4. Using Bind Variables with Cold Fusion and Oracle
    By Niall Litchfield in forum Oracle Server
    Replies: 3
    Last Post: July 3rd, 03:04 PM
  5. MYSQL, PHP and Bind variables in SQL
    By Jack in forum PHP Development
    Replies: 2
    Last Post: June 27th, 01:21 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139