Here is a description of the testcase for the problem:
Oracle:
Create table Mytable (
Username varchar2(20),
Passwd varchar2(20),
Usertype varchar2(50))
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
> -----Original Message-----
> From: Thies C. Arntzen [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 26, 2001 6:10 PM
> To: Victoria Zhou
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP-INST] PHP datatype vs Oracle Varchar2
>
>
> On Thu, Jul 26, 2001 at 05:08:42PM -0500, Victoria Zhou wrote:
> >
> > Hi,
> >
> > The comparison between Oracle VARCHAR2 and a PHP string doesn't seems to
> > work. Detail as follows:
> >
> > I have one PHP variable and one Oracle column:
> > . $form_user_id: a PHP string obtained from web form input,
> such as 'user1'.
> > . Username: an oracle table column of type VARCHAR2(20).
> >
> > The following sql statement failed:
> > "select * from mytable where Username='$form_user_id'"
> >
> > It failed because Username has a strlen of 20, where $form_user_id has a
> > strlen of 5. If I changed the Username from VARCHAR2(20) to
> CHAR(20), then
> > this sql worked fine. But I think with Oracle VARCHAR2, the strlen of
> > Username in this case should be 5 instead of 20.
>
> you must be doing something wrong here;-)
>
> please try to create a _tiny_ testcase (< 20 lines) and post
> it to the list, i'm sure you're overseeing something
> important.
>
> tc
>
>
--
PHP Install Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]