PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ora_errorcode> <ora_do
Last updated: Mon, 26 Nov 2007

view this page in

ora_error

(PHP 4, PHP 5 <= 5.0.5)

ora_error — 获得 Oracle 错误信息

描述

string ora_error ([ resource $cursor_or_connection ] )

返回一个 XXX-NNNNN 形式的错误信息,XXX 报告错误来源, NNNNN 报告错误号。

Note: 对 connection ids 的支持从 3.0.4 开始。

在 Unix 版的 Oracle 上,你会发现关于某个错误信息的详细内容与下面的显示类似: $ oerr ora 00001 00001, 00000, "unique constraint (%s.%s) violated" // *Cause: An update or insert statement attempted to insert a duplicate key // For Trusted ORACLE configured in DBMS MAC mode, you may see // this message if a duplicate entry exists at a different level. // *Action: Either remove the unique restriction or do not insert the key



ora_errorcode> <ora_do
Last updated: Mon, 26 Nov 2007
 
add a note add a note User Contributed Notes
ora_error
rob at towner dot cx
18-May-2004 07:56
You can use ora_error() to output the reason for a failed ora_logon() connection attempt. To do this, call ora_error() without any parameters. This works for php versions >= 4.0.2.

<?php
$conn
= @ora_logon("user@wrongTNS", "pass");

if (!
$conn) {
    echo
"Unable to connect to the database.<BR>\n";
    echo
ora_error(), "\n";
}
?>

This will output:

Unable to connect to the database.<BR>
ORA-12154: TNS:could not resolve service name
mihailsbo at lycos dot ru
17-Jun-2003 05:52
When your program is performing an Ora_Fetch, and your session is terminated by a database administrator, your fetch will fail, but the ora_error( your_connection ) will return 0. You can check the ora_error( your_cursor ), it will return 28 (ORA-00028: your session has been killed).
weiliang at yahoo dot com
10-Oct-2002 05:25
# Check this one out. PHP 4.2.2 with Oracle nad OCI8
<?php

    
class panera_oracle
    
{
       
       
/* Private Variables      ******************************************* */
       
       
var $db_conn;
        var
$db_cursor;
        var
$db_record_set;
 
       
/* Open an Oracle connect ****************************************** */

       
function connect($orauser, $tns, $password)
        {
           
$conn_str=$orauser . '@' . $tns;

           
$conn = ora_logon($conn_str,$password);
            if (!
$conn )
            {
              
$this->post_ora_error($conn);
              
$this->db_conn = "NULL";
            }
            else
            { 
$this->db_conn = $conn; }

            return;
        }

       
/* Disconnect from Oracle ****************************************** */

       
function disconnect()
        {
           
ora_logoff($this->db_conn);
            return;
        }

       
/* Post ORA - Error ***** ****************************************** */

       
function post_ora_error($ora_handle)
        {
            if (
ora_errorcode($ora_handle) )
            {
               echo
"Oracle Error - ".ora_error($ora_handle)."<br>\n";
               return -
1;
            }
            return
1;
        }

       
/* Execute query and return cursor handle ************************* */
       
       
function execute_query($query)
        {
          
$this->db_cursor=ora_open($this->db_conn);
           if (
$this->post_ora_error($this->db_cursor) > 0 )
           {
              
ora_parse($this->db_cursor,$query,0);
               if (
$this->post_ora_error($this->db_cursor) > 0 )
               {
                 
ora_exec($this->db_cursor);
                  if (
$this->post_ora_error($this->db_cursor) > 0 )
                  {
                     return
1;
                  }
                  else { return -
1; }
               }
               else { return -
1; }
           }
           else { return -
1; }
           
        }
    }

?>

<?php

     $oracle
= new panera_oracle;
    
$query="SELECT * from AUDIT_LOAD_TYPES order by load_type_id";

    
$oracle->connect("pan_ods","shekel_proddw","panods");
   
     if (
$oracle->execute_query($query) > 0 )
     {
       
$oracle->db_record_set = array();

        while (
ora_fetch_into($oracle->db_cursor, $oracle->db_record_set, ORA_FETCHINTO_NULLS | ORA_FETCHINTO_ASSOC) )
        {
                echo
$oracle->db_record_set['LOAD_TYPE_ID']   . " ";
                echo
$oracle->db_record_set['LOAD_TYPE_DESC'] . " ";
                echo
$oracle->db_record_set['PACKAGE_NAME']   . " ";
                echo
$oracle->db_record_set['PROCEDURE_NAME'] . " ";

               
$rows=ora_numrows($oracle->db_cursor);

                echo
$rows;
                echo
"<BR>";
         }
     }

    
ora_close($oracle->db_cursor);
    
$oracle->disconnect();

?>

ora_errorcode> <ora_do
Last updated: Mon, 26 Nov 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites