Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Oracle Functions [deprecated] : ora_error

ora_error

Gets an Oracle error message (PHP 4, PHP 5 <= 5.0.5)
string ora_error ( [resource cursor_or_connection] )


Code Examples / Notes » ora_error

rob

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.
\n";
   echo ora_error(), "\n";
}
?>
This will output:
Unable to connect to the database.
ORA-12154: TNS:could not resolve service name


mihailsbo

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

# 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)."
\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 "
";
        }
    }
    ora_close($oracle->db_cursor);
    $oracle->disconnect();
?>


Change Language


Follow Navioo On Twitter
ora_bind
ora_close
ora_columnname
ora_columnsize
ora_columntype
ora_commit
ora_commitoff
ora_commiton
ora_do
ora_error
ora_errorcode
ora_exec
ora_fetch_into
ora_fetch
ora_getcolumn
ora_logoff
ora_logon
ora_numcols
ora_numrows
ora_open
ora_parse
ora_plogon
ora_rollback
eXTReMe Tracker