RE: [PHP-INST] PHP datatype vs Oracle Varchar2
| From: | Benjamin Heckmann | Date: | Fri, 27 Jul 2001 07:59:40 +0000 |
| Subject: | RE: [PHP-INST] PHP datatype vs Oracle Varchar2 | ||
| Groups: | php.install | ||
| Request: | Send a blank email to php-install+get-3723@lists.php.net to get a copy of this message | ||
> Here is a description of the testcase for the problem:
>
> Oracle:
> Create table Mytable (
> Username varchar2(20),
> Passwd varchar2(20),
> Usertype varchar2(50))
So, why are you using VARCHAR2 for this case? If you used
the simple VARCHAR for all of your columns this problem
would not occure?!
>
> Insert into Mytable (Username, Passwd, Usertype)
> values(\'tester1\',\'tester1\',\'Operator\');
>
> PHP:
> $sql = \"select * from Mytable where Username=\'tester1\'\";
> $sql_statement = OCIParse($conn, $sql) or die (\"Couldn\'t parse
statement\");
> OCIExecute($sql_statement) or die (\"Couldn\'t execute query\");
>
>
> Problem:
> The string comaparison in the $sql (Username=\'tester1\') is never true,
> because Username is a variable length string and \'tester1\' is considered
as
> a fixed length string.
>
> I don\'t have the flexibility to change VARCHAR2 to CHAR in order to make
> this work, because a fixed length string will cause a lot of trouble for
> string comparisons for other code in the program.
>
> Thanks for your help!
>
> Victoria
>
Benjamin