I am having difficulty maintaining a consistant connection between a statically linked apache(PHP4+OCI8) and a remote ORACLE database.
I have repeatedly had success sending SQL statments and getting good data in return. More often than; however, my browser will freeze and if I wait long enough I will get a timeout message ora-12537 I think.
This is a code segment showing what I am doing:
//Oracle.php
<?PHP
PutEnv("ORACLE_SID=remotesid");
PutEnv("ORACLE_HOME=/opt/oracle/orahome");
PutEnv("NLS_LANG=american.american.US7ASCII");
$ORAUSER = "userid";
$ORAPASS = "password";
$ORALINK = "(DESCRIPTION = (FAILOVER=ON) (LOAD_BALANCE=OFF)(ADDRESS=(PROTOCOL=TCP)(HOST=remote.oracle.host.com)(PORT=1521)) (CONNECT_DATA=(SID=remotesid) ) )";
function PerformOCISelect($Query)
{
//OCIInternalDebug(1);
global $ORAUSER,$ORAPASS,$ORALINK;
if(!($cnct = OCIPLogon($ORAUSER,$ORAPASS,$ORALINK)))
{
return $cnct;
}
if(!($stmt = OCIParse($cnct,$Query) ))
{
OCILogoff($cnct);
return $stmt;
}
if(!($result = OCIExecute($stmt) ))
{
OCIFreeStatement($stmt);
OCILogoff($cnct);
return $result;
}
$RowArray = array();
$FieldArray = array();
while( OCIFetchInto($stmt,$FieldArray) )
{
$RowArray[] = $FieldArray;
}
OCIFreeStatement($stmt);
OCILogoff($cnct);
return $RowArray;
}
In my code ...
<?PHP
include "Includes/Oracle.php";
...
if(! ($RowArray = PerformOCISelect("SELECT * FROM DB.USER_TABLE WHERE ROWNUM<15") ) )
{
echo OCIError($RowArray);
exit;
}
...
?>
Thanks in advance for any help.
I have repeatedly had success sending SQL statments and getting good data in return. More often than; however, my browser will freeze and if I wait long enough I will get a timeout message ora-12537 I think.
This is a code segment showing what I am doing:
//Oracle.php
<?PHP
PutEnv("ORACLE_SID=remotesid");
PutEnv("ORACLE_HOME=/opt/oracle/orahome");
PutEnv("NLS_LANG=american.american.US7ASCII");
$ORAUSER = "userid";
$ORAPASS = "password";
$ORALINK = "(DESCRIPTION = (FAILOVER=ON) (LOAD_BALANCE=OFF)(ADDRESS=(PROTOCOL=TCP)(HOST=remote.oracle.host.com)(PORT=1521)) (CONNECT_DATA=(SID=remotesid) ) )";
function PerformOCISelect($Query)
{
//OCIInternalDebug(1);
global $ORAUSER,$ORAPASS,$ORALINK;
if(!($cnct = OCIPLogon($ORAUSER,$ORAPASS,$ORALINK)))
{
return $cnct;
}
if(!($stmt = OCIParse($cnct,$Query) ))
{
OCILogoff($cnct);
return $stmt;
}
if(!($result = OCIExecute($stmt) ))
{
OCIFreeStatement($stmt);
OCILogoff($cnct);
return $result;
}
$RowArray = array();
$FieldArray = array();
while( OCIFetchInto($stmt,$FieldArray) )
{
$RowArray[] = $FieldArray;
}
OCIFreeStatement($stmt);
OCILogoff($cnct);
return $RowArray;
}
In my code ...
<?PHP
include "Includes/Oracle.php";
...
if(! ($RowArray = PerformOCISelect("SELECT * FROM DB.USER_TABLE WHERE ROWNUM<15") ) )
{
echo OCIError($RowArray);
exit;
}
...
?>
Thanks in advance for any help.