Re: Oracle8 and varchar
| From: | Olivier Lepretre | Date: | Wed, 28 Jun 2000 10:23:35 +0000 |
| Subject: | Re: Oracle8 and varchar | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-681@lists.php.net to get a copy of this message | ||
Hi Rouvas :
This is the code. the column b.proc_desc is the varchar2(20) causing problem (and all varchar2
fields are causing me the same problem). if the value is for example GUIDE, the function strlen
returns a size of 10 ..... but the real size is 5 .... After investigation, it appears that the
string is composed of G\0U\0I\0D\0E\0 .... strange isn't it ?
The server is ORA/NT 8.0.5, client is on RH6.1 ORA8.0.x
here is the source
<?php
putenv("ORACLE_HOME=/app/oracle/product/8.0.5");
putenv("ORACLE_SID=AFR1");
print "<HTML>\n";
$conn = OCILogon("admafr1", "mypasswd","afr1");
$query= " select log_ldexec, log_lyproc, log_ldproc, b.proc_desc
\"DESC\" ";
$query.= " from afr_syslog a, afr_sysprocess b";
$query.= " where a.proc_id=b.proc_id order by log_ldexec";
$stmt = OCIParse($conn,$query);
ocidefinebyname($stmt,"LOG_LDEXEC",&$vlog_ldexec);
ocidefinebyname($stmt,"LOG_LYPROC",&$vlog_lyproc);
ocidefinebyname($stmt,"LOG_LDPROC",&$vlog_ldproc);
ocidefinebyname($stmt,"DESC",&$vdesc);
ociexecute($stmt, OCI_DEFAULT);
print "<TABLE BORDER=\"0\" Cellspacing=\"2\">";
print "<TR bgcolor=\"DDDDDD\">";
print "<TH> <FONT face=\"Arial\" size=\"-1\">
Execution Date </FONT></TH>";
print "<TH> <FONT face=\"Arial\" size=\"-1\">
Process </FONT></TH>";
print "<TH> <FONT face=\"Arial\" size=\"-1\">
size </FONT></TH>";
print "<TH> <FONT face=\"Arial\" size=\"-1\">
Day processed </FONT></TH>";
print "</TR>";
print "<TR></TR>";
while (OCIFetch($stmt))
{
print "<TR >";
print "<TD align=\"center\"> <FONT
face=\"Arial\" size=\"-1\"> ".$vlog_ldexec."
</FONT></TD>\n";
print "<TD> <FONT face=\"Arial\"
size=\"-1\"> " .$vdesc."</FONT></TD>\n";
print "<TD align=\"center\"> <FONT
face=\"Arial\" size=\"-1\">".strlen($vdesc)."
</FONT></TD>\n";
print "<TD align=\"center\"> <FONT
face=\"Arial\" size=\"-1\"> ".$vlog_ldproc."</FONT>
</TD>\n";
print "</TR>";
}
OCIFreeStatement($stmt);
OCILogoff($conn);
print "</HTML>\n";
?>
And the result is
Execution Date Process size Day processed
23-JUN-00 Guide 10 174
23-JUN-00 Asr comp. 18 159
23-JUN-00 Asr comp. 18 160
23-JUN-00 Asr comp. 18 161
23-JUN-00 Asr comp. 18 162
23-JUN-00 CC Detecti 20 163
23-JUN-00 Asr comp. 18 164
23-JUN-00 Asr comp. 18 165
23-JUN-00 Asr comp. 18 166
23-JUN-00 Asr comp. 18 167
23-JUN-00 Asr comp. 18 168
23-JUN-00 Asr comp. 18 169
23-JUN-00 Asr comp. 18 170
23-JUN-00 Asr comp. 18 171
23-JUN-00 Asr comp. 18 172
23-JUN-00 Asr comp. 18 173
23-JUN-00 Asr comp. 18 174
24-JUN-00 Load 9F 14 175
24-JUN-00 Load 9F 14 175
24-JUN-00 Load 8A 14 173
If you have any idea ...
thanks in advance.
----- Original Message -----
From: "Rouvas Stathis" <rouvas@di.uoa.gr>
To: "Olivier Lepretre" <olivier.lepretre@afrilink.net>
Cc: <php-db@lists.php.net>
Sent: Wednesday, June 28, 2000 12:08 PM
Subject: Re: [PHP-DB] Oracle8 and varchar
> What exaclty ar you doing? Some code would be useful. I haven't
> encoutered any problems so far.
> I've used NT/Ora8i, Solaris/Ora.8.0.xx and SuSE/Ora.8.0.xx so far with
> no problems.
> -Stathis.
>
>
> Olivier Lepretre wrote:
> >
> > When I fetch a column of type varchar2 with php3, php is returning only the halfsize of
> > the column, one caracter on two is a \0. The result is always truncated to the size of the column,
> > but including the \0s.
> >
> > Exemple : column toto is varchar2(10) containing ABCDEFGHIJ
> >
> > Php is returning : A\0B\0C\0D\0E\0 wich is print ABCDE ... It misses the five last letters
> > because Php had already count 10 chars ....
> >
> > Could anyone help me, I don't want to double the size of all my varchars fields !!!
> >
> > Thanks a lot
> >
> > __________________
> > Olivier Lepretre
> > Afrilink Belgium S.A.
> > IT Manager
>
> --
> +-----------------------------+
> |Rouvas Stathis |
> |University of Athens |
> |Department of Informatics |
> |http://www.di.uoa.gr/~rouvas |
> |rouvas@di.uoa.gr |
> +-----------------------------+
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>