Professional Web Applications Themes

#14013 [Com]: ocibindbyname strips trailing spaces - PHP Development

ID: 14013 Comment by: m dot ford at lmu dot ac dot uk Reported By: az at i7 dot com dot au Status: Closed Bug Type: OCI8 related Operating System: Linux 2.2, Solaris 2.6 PHP Version: 4.0.6 New Comment: There still doesn't seem to be a satisfactory explanation posted here, and it's still Open, so could someone please address the salient issue: If the database column is defined as VARCHAR2, why does this strip trailing blanks on the inserted value: $text = " this line has spaces "; $st = ocip($db, "insert into test values (:text)"); ocibindbyname($st, ":text", &$text, 2000); ...

  1. #1

    Default #14013 [Com]: ocibindbyname strips trailing spaces

    ID: 14013
    Comment by: m dot ford at lmu dot ac dot uk
    Reported By: az at i7 dot com dot au
    Status: Closed
    Bug Type: OCI8 related
    Operating System: Linux 2.2, Solaris 2.6
    PHP Version: 4.0.6
    New Comment:

    There still doesn't seem to be a satisfactory explanation posted here,
    and it's still Open, so could someone please address the salient
    issue:

    If the database column is defined as VARCHAR2, why does this strip
    trailing blanks on the inserted value:

    $text = " this line has spaces ";
    $st = ocip($db, "insert into test values (:text)");
    ocibindbyname($st, ":text", &$text, 2000);
    ociexecute($st);

    whilst this does not:

    $text = " this line has spaces ";
    $st = ocip($db, "insert into test values '$text')");
    ociexecute($st);


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

    [2003-01-31 09:36:03] jens dot reibiger at rp dot vaw dot com

    It seems, that I have the same problem using PHP 4.3.0 on Apache 1.3.22
    with Oracle 8.1.7:

    When I use a OciBindByName, the string is trimed at the end. This small
    program uses the DUAL from Oracle just to return the input:

    $conn = OciLogon ("x","y","z");
    $val = " X X "; // last letter is a " " (blank)

    // direct way without a bind variable
    $stm1 = OciP($conn, "select '".$val."' from dual");
    OciExecute($stm1);
    OciFetch($stm1);
    echo "<b>", OciResult($stm1, 1), "</b><br>\n";

    // now using a bind variable:
    $stm2 = OciP($conn, "select :input from dual");
    OciBindByName($stm2, ":input", &$val, 10);
    OciExecute($stm2);
    OciFetch($stm2);
    echo "<b>", OciResult($stm2, 1), "</b><br>\n";

    OciLogoff($conn);


    The output is:

    <b> X X </b><br>
    <b> X X</b><br>

    But I want to get the same output for the direct way and when I use a
    bind variable.

    Thank you for any idea how to get the string with tailing spaces right
    into Oracle using a bind variable.

    Best wishes,
    Jens

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

    [2002-04-13 08:58:13] [email]thiesphp.net[/email]

    try storing in a varchar2 firld, if you use CHAR oracle will trim
    traing spaces.


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

    [2001-11-11 06:49:19] az at i7 dot com dot au

    Erm, yeah, that's supposed to be '$id = 666;'.

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

    [2001-11-11 03:28:34] az at i7 dot com dot au

    When inserting text using named binds, PHP will strip trailing spaces.
    The same query on the same database using the same Oracle client
    libraries. (All Oracle 8.1.6)

    $db = ocilogon("u", "p", "sid");
    $st = ocip($db, "insert into test values (:id, :text)");
    ocibindbyname($st, ":text", &$text, 2000);
    ocibindbyname($st, ":id", &$id, 22);
    $text = " this line has spaces ";
    $node_id = 666;
    ociexecute($st);


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


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

    m dot ford at lmu dot ac dot uk Guest

  2. #2

    Default #14013 [Com]: ocibindbyname strips trailing spaces

    ID: 14013
    Comment by: m dot ford at lmu dot ac dot uk
    Reported By: az at i7 dot com dot au
    Status: Closed
    Bug Type: OCI8 related
    Operating System: Linux 2.2, Solaris 2.6
    PHP Version: 4.0.6
    New Comment:

    My mistake -- it's Closed, not Open ("green means Closed, green means
    Closed!"), but, to my mind, still without satisfactory explanation.

    Cheers!


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

    [2003-08-18 11:49:55] m dot ford at lmu dot ac dot uk

    There still doesn't seem to be a satisfactory explanation posted here,
    and it's still Open, so could someone please address the salient
    issue:

    If the database column is defined as VARCHAR2, why does this strip
    trailing blanks on the inserted value:

    $text = " this line has spaces ";
    $st = ocip($db, "insert into test values (:text)");
    ocibindbyname($st, ":text", &$text, 2000);
    ociexecute($st);

    whilst this does not:

    $text = " this line has spaces ";
    $st = ocip($db, "insert into test values '$text')");
    ociexecute($st);

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

    [2003-01-31 09:36:03] jens dot reibiger at rp dot vaw dot com

    It seems, that I have the same problem using PHP 4.3.0 on Apache 1.3.22
    with Oracle 8.1.7:

    When I use a OciBindByName, the string is trimed at the end. This small
    program uses the DUAL from Oracle just to return the input:

    $conn = OciLogon ("x","y","z");
    $val = " X X "; // last letter is a " " (blank)

    // direct way without a bind variable
    $stm1 = OciP($conn, "select '".$val."' from dual");
    OciExecute($stm1);
    OciFetch($stm1);
    echo "<b>", OciResult($stm1, 1), "</b><br>\n";

    // now using a bind variable:
    $stm2 = OciP($conn, "select :input from dual");
    OciBindByName($stm2, ":input", &$val, 10);
    OciExecute($stm2);
    OciFetch($stm2);
    echo "<b>", OciResult($stm2, 1), "</b><br>\n";

    OciLogoff($conn);


    The output is:

    <b> X X </b><br>
    <b> X X</b><br>

    But I want to get the same output for the direct way and when I use a
    bind variable.

    Thank you for any idea how to get the string with tailing spaces right
    into Oracle using a bind variable.

    Best wishes,
    Jens

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

    [2002-04-13 08:58:13] [email]thiesphp.net[/email]

    try storing in a varchar2 firld, if you use CHAR oracle will trim
    traing spaces.


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

    [2001-11-11 06:49:19] az at i7 dot com dot au

    Erm, yeah, that's supposed to be '$id = 666;'.

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

    [2001-11-11 03:28:34] az at i7 dot com dot au

    When inserting text using named binds, PHP will strip trailing spaces.
    The same query on the same database using the same Oracle client
    libraries. (All Oracle 8.1.6)

    $db = ocilogon("u", "p", "sid");
    $st = ocip($db, "insert into test values (:id, :text)");
    ocibindbyname($st, ":text", &$text, 2000);
    ocibindbyname($st, ":id", &$id, 22);
    $text = " this line has spaces ";
    $node_id = 666;
    ociexecute($st);


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


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

    m dot ford at lmu dot ac dot uk Guest

  3. #3

    Default #14013 [Com]: ocibindbyname strips trailing spaces

    ID: 14013
    Comment by: russ at iris dot washington dot edu
    Reported By: az at i7 dot com dot au
    Status: Closed
    Bug Type: OCI8 related
    Operating System: Linux 2.2, Solaris 2.6
    PHP Version: 4.0.6
    New Comment:

    I also wonder why this is closed.
    Just encountered a simpler case:

    I cannot select using this field:

    LOCATION NOT NULL VARCHAR2(2)

    those records which have ' ' (two spaces) for
    that LOCATION's value. Non-space values work fine.
    Interactive SQLPLUS confirms those rows do exist.

    Oracle 8
    PHP 4.3.1
    Solaris SunOS dmc 5.7 sun4u sparc SUNW,Ultra-Enterprise


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

    [2003-08-18 11:52:36] m dot ford at lmu dot ac dot uk

    My mistake -- it's Closed, not Open ("green means Closed, green means
    Closed!"), but, to my mind, still without satisfactory explanation.

    Cheers!

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

    [2003-08-18 11:49:55] m dot ford at lmu dot ac dot uk

    There still doesn't seem to be a satisfactory explanation posted here,
    and it's still Open, so could someone please address the salient
    issue:

    If the database column is defined as VARCHAR2, why does this strip
    trailing blanks on the inserted value:

    $text = " this line has spaces ";
    $st = ocip($db, "insert into test values (:text)");
    ocibindbyname($st, ":text", &$text, 2000);
    ociexecute($st);

    whilst this does not:

    $text = " this line has spaces ";
    $st = ocip($db, "insert into test values '$text')");
    ociexecute($st);

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

    [2003-01-31 09:36:03] jens dot reibiger at rp dot vaw dot com

    It seems, that I have the same problem using PHP 4.3.0 on Apache 1.3.22
    with Oracle 8.1.7:

    When I use a OciBindByName, the string is trimed at the end. This small
    program uses the DUAL from Oracle just to return the input:

    $conn = OciLogon ("x","y","z");
    $val = " X X "; // last letter is a " " (blank)

    // direct way without a bind variable
    $stm1 = OciP($conn, "select '".$val."' from dual");
    OciExecute($stm1);
    OciFetch($stm1);
    echo "<b>", OciResult($stm1, 1), "</b><br>\n";

    // now using a bind variable:
    $stm2 = OciP($conn, "select :input from dual");
    OciBindByName($stm2, ":input", &$val, 10);
    OciExecute($stm2);
    OciFetch($stm2);
    echo "<b>", OciResult($stm2, 1), "</b><br>\n";

    OciLogoff($conn);


    The output is:

    <b> X X </b><br>
    <b> X X</b><br>

    But I want to get the same output for the direct way and when I use a
    bind variable.

    Thank you for any idea how to get the string with tailing spaces right
    into Oracle using a bind variable.

    Best wishes,
    Jens

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

    [2002-04-13 08:58:13] net

    try storing in a varchar2 firld, if you use CHAR oracle will trim
    traing spaces.


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

    [2001-11-11 06:49:19] az at i7 dot com dot au

    Erm, yeah, that's supposed to be '$id = 666;'.

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

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    http://bugs.php.net/14013

    --
    Edit this bug report at http://bugs.php.net/?id=14013&edit=1
    russ Guest

Similar Threads

  1. Replies: 2
    Last Post: October 13th, 05:07 PM
  2. AI CS makes PDFs with data in strips, showing white between strips
    By Kirby_Spencer@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 0
    Last Post: April 23rd, 08:27 PM
  3. OCIBindByName & pass-by-reference
    By Laurent Drouet in forum PHP Development
    Replies: 0
    Last Post: September 17th, 08:28 AM
  4. Test strips?
    By Hazel Harrison in forum Adobe Photoshop Elements
    Replies: 5
    Last Post: August 8th, 03:47 PM
  5. No trailing spaces after closing here doc tag?
    By Chris Morris in forum Ruby
    Replies: 1
    Last Post: August 6th, 02:50 AM

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