|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-02-19 13:06 UTC] marvin at chag dot net
Description:
------------
Problem is, that more or less often (not always) the call to OCIPLogon (or OCILogon) results into an Oracle error message "ORA-02248: invalid option for ALTER SESSION" and the connection to the database is not made.
Everything worked fine up to PHP 5.1.1 but all other versions starting from 5.1.2 up to 5.2.1 are showing this "ALTER SESSION" behavior.
The Oracle related environment for Apache startup is:
export ORACLE_SID=db
export ORACLE_TERM=vt220
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/8.1.7
export CLASSPATH=$ORACLE_HOME/jdbc/lib/classes111.zip
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:$ORACLE_HOME/bin
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export NLS_LANG=GERMAN_GERMANY.WE8ISO8859P1
Webserver:
Linux 2.4.21-303-smp4G
Apache 1.3.37 + SSL Patch 1.57
PHP 5.2.1 compiled statically into Apache
Oracle Client 8.1.7.0.0
Database:
Oracle from version 8.1.6 to 8.1.7.0.4 running on different Linux and Windows
PHP configure line:
./configure --with-ldap --enable-dbase --with-mysql --with-oci8 --with-oracle --with-gd --with-jpeg-dir --with-png-dir --with-tiff-dir --with-xpm-dir --enable-calendar --enable-sigchild --with-zlib --with-bz2 --enable-ftp --enable-sockets --with-apache=../apache_1.3.37 --with-gettext --enable-bcmath --with-mcrypt --with-mhash --with-ttf=/usr/include/freetype --with-gmp --enable-trans-sid --with-freetype-dir=/usr/include/freetype2 --enable-gd-native-ttf --with-libxml-dir --enable-soap
Reproduce code:
---------------
<?
OCIInternalDebug(1);
for ($i = 1; $i <= 10; $i++)
{
$con = @OCIPLogon("<user>","<pass>","<db>");
if ($con == true)
break;
else
{
echo var_dump(OCIError());
break;
}
};
?>
Expected result:
----------------
OCIPLogon() should give a valid DB connection.
Actual result:
--------------
When the connect is not working, DEBUG shows the following:
OCI8 DEBUG: OCIEnvCreate at (/php-5.2.1/ext/oci8/oci8.c:1216)
OCI8 DEBUG: OCIHandleAlloc at (/php-5.2.1/ext/oci8/oci8.c:1239)
OCI8 DEBUG: OCIServerAttach at (/php-5.2.1/ext/oci8/oci8.c:1248)
OCI8 DEBUG: OCIHandleAlloc at (/php-5.2.1/ext/oci8/oci8.c:1258)
OCI8 DEBUG: OCIHandleAlloc at (/php-5.2.1/ext/oci8/oci8.c:1267)
OCI8 DEBUG: OCIHandleAlloc at (/php-5.2.1/ext/oci8/oci8.c:1276)
OCI8 DEBUG: OCIAttrSet at (/php-5.2.1/ext/oci8/oci8.c:1286)
OCI8 DEBUG: OCIAttrSet at (/php-5.2.1/ext/oci8/oci8.c:1297)
OCI8 DEBUG: OCIAttrSet at (/php-5.2.1/ext/oci8/oci8.c:1307)
OCI8 DEBUG: OCIAttrSet at (/php-5.2.1/ext/oci8/oci8.c:1316)
OCI8 DEBUG: OCISessionBegin at (/php-5.2.1/ext/oci8/oci8.c:1350)
OCI8 DEBUG: OCIErrorGet at (/php-5.2.1/ext/oci8/oci8.c:922)
OCI8 DEBUG: OCIHandleFree at (/php-5.2.1/ext/oci8/oci8.c:1514)
OCI8 DEBUG: OCIServerDetach at (/php-5.2.1/ext/oci8/oci8.c:1518)
OCI8 DEBUG: OCIHandleFree at (/php-5.2.1/ext/oci8/oci8.c:1522)
OCI8 DEBUG: OCIHandleFree at (/php-5.2.1/ext/oci8/oci8.c:1526)
OCI8 DEBUG: OCIHandleFree at (/php-5.2.1/ext/oci8/oci8.c:1530)
OCI8 DEBUG: OCIHandleFree at (/php-5.2.1/ext/oci8/oci8.c:1534)
DEBUG XXX
OCI8 DEBUG: OCIErrorGet at (/php-5.2.1/ext/oci8/oci8.c:922) array(4) { ["code"]=> int(604) ["message"]=> string(94) "ORA-00604: error occurred at recursive SQL level 1 ORA-02248: invalid option for ALTER SESSION" ["offset"]=> int(0) ["sqltext"]=> string(0) "" }
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 11:00:01 2025 UTC |
I've found the following workaround for that problem: - Instead of setting the NLS_LANG environment variable, you can specify the charset while establishing the connection: $conn=oci_connect("USER","PASSWORD","SERVER","CHARSET"); Where charset should be the one used by PHP client (not the one used by the Oracle server). In the case of a windows system, it is "WE8MSWIN1252" (In my PHP server, this code is specified in the NLS_LANG registry key, but oci_connect doesn't take it as default value). It is "WE8MSWIN1252" even if the PHP is executed as a script, from the command line. The CHARSET for a linux/unix system may be "WE8ISO8851P1", or at least it seems to be usual in Europe.