Re: Oracle8 and varchar
| From: | Olivier Lepretre | Date: | Wed, 28 Jun 2000 12:24:27 +0000 |
| Subject: | Re: Oracle8 and varchar | ||
| References: | 1 2 3 4 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-688@lists.php.net to get a copy of this message | ||
Well ...
I've tried the 3 options, my nls_language is set to american, the
ociFetchInto gives the same result and
when putting the optional parameter (size) in ocidefinebyname, it still
doest work ...
Just to inform, I have the same problems with chars .... (ex CHAR(2) )
Thanks a lot
If you have more ideas ... I'm looking for a solution since monday !!
----- 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:50 PM
Subject: Re: [PHP-DB] Oracle8 and varchar
> Well, the code seems Ok to me.
> I have the following suggestions:
>
> 1) Check out the NLS_LANG env-var as suggested in previous posts.
>
> 2) Try the same using OCIFetchInto() call. As an example, here is a
> snippet of mine:
> $sel = "select portfname,usrtext,notify from afeportf where
> usrid=$usrid and portfid=$portfid and
> subportfid=$subportfid";
> $stmt = ociparse($cone, $sel); @ociexecute($stmt);
> OCIFetchInto($stmt,&$result,OCI_NUM+OCI_RETURN_NULLS);
> $ui_portfname = decodestr($result[0]);
> $ui_usrtext = decodestr($result[1]);
> $ui_notify = decodestr($result[2]);
>
> 3) I think that the call to ocidefinebyname() takes a last argument of
> int. If you try it in PL/SQL stored procs you are obliged to also
> specify the length of the returning variable.
> From Ora manual
>
<URL:http://aspasia.mm.di.uoa.gr/inet/orasupport/html804/server/a58241/ch10.
htm#5871>:
>
> <ora-manual>
> The following syntax is also supported for BIND_VARIABLE. The square
> brackets [] indicate an optional
> parameter for the BIND_VARIABLE function.
>
> DBMS_SQL.BIND_VARIABLE(
> c IN INTEGER,
> name IN VARCHAR2,
> value IN VARCHAR2 CHARACTER SET ANY_CS
> [,out_value_size IN INTEGER]);
>
> To bind CHAR, RAW, and ROWID data, you can use the following variations
> on the syntax:
>
> DBMS_SQL.BIND_VARIABLE_CHAR(
> c IN INTEGER,
> name IN VARCHAR2,
> value IN CHAR CHARACTER SET ANY_CS
> [,out_value_size IN INTEGER]);
> DBMS_SQL.BIND_VARIABLE_RAW(
> c IN INTEGER,
> name IN VARCHAR2,
> value IN RAW
> [,out_value_size IN INTEGER]);
> DBMS_SQL.BIND_VARIABLE_ROWID(
> c IN INTEGER,
> name IN VARCHAR2,
> value IN ROWID);
> </ora-manual>
>
> It seems strange to me that PHP does not require the same argument as it
> eventually calls OCI() functions.
>
> Hope that helps,
> -Stathis.
>
>
> Olivier Lepretre wrote:
> >
> > 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
> > >
>
> --
> +-----------------------------+
> |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
>