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

search for in the

oci_fetch_all> <oci_error
Last updated: Fri, 06 Nov 2009

view this page in

oci_execute

(PHP 5, PECL oci8 >= 1.1.0)

oci_executeExecutes a statement

Descrierea

bool oci_execute ( resource $statement [, int $mode = OCI_COMMIT_ON_SUCCESS ] )

Executes a previously parsed statement .

Parametri

statement

A valid OCI statement identifier.

mode

Allows you to specify the execution mode (default is OCI_COMMIT_ON_SUCCESS).

If you don't want statements to be committed automatically, you should specify OCI_DEFAULT as your mode .

When using OCI_DEFAULT mode, you're creating a transaction. Transactions are automatically rolled back when you close the connection, or when the script ends, whichever is soonest. You need to explicitly call oci_commit() to commit the transaction, or oci_rollback() to abort it.

Valorile întroarse

Întoarce valoarea TRUE în cazul succesului sau FALSE în cazul eşecului.

Note

Notă: In PHP versions before 5.0.0 you must use ociexecute() instead. This name still can be used, it was left as alias of oci_execute() for downwards compatability. This, however, is deprecated and not recommended.

Vedeţi de asemenea

  • oci_parse() - Prepares Oracle statement for execution



oci_fetch_all> <oci_error
Last updated: Fri, 06 Nov 2009
 
add a note add a note User Contributed Notes
oci_execute
sixd at php dot net
07-Oct-2009 01:09
(PHP 5.3.2 (aka PECL OCI8 >= 1.4) adds a new constant that can be used with oci_execute().  It is an alias of OCI_DEFAULT.

OCI_NO_AUTO_COMMIT (integer)

  Statement execution mode. Statement is not committed automatically
  when using this mode.  For readability, use OCI_NO_AUTO_COMMIT
  instead of the obsolete OCI_DEFAULT constant.
pcythe at gmail dot com
29-Oct-2008 01:38
In addition to executing the previously parsed statement, oci_execute also validates the SQL query being passed to oci_parse.

If an error is detected oci_execute gives a "ORA-00900: invalid SQL statement" warning.
23-Feb-2006 05:56
Mode OCI_DESCRIBE_ONLY is supported as of the fix to http://bugs.php.net/bug.php?id=36403
Flo at yahoo dot com
17-Jun-2004 11:40
Termin.php
<?php
  session_start
();
  if(!
session_is_registered("db"))
  {
   
$_SESSION["user"] = $_POST["user"];
   
$_SESSION["pass"] = $_POST["pass"];
   
$_SESSION["db"] = $_POST["db"];
  }
 
$logdata[0] = $_SESSION["user"];
 
$logdata[1] = $_SESSION["pass"];
 
$logdata[2] = $_SESSION["db"];
 
$conn = OCILogon($logdata[0],$logdata[1],$logdata[2]);
 
 
$sql = "Select T.TEID, TEDATUM, TEUhrzeit, TEORT, TEBeschreibung, KLID as GRID, KLBezeichnung as Bezeichnung From TTermine T, TGruppetermin G, TKLASSE K Where T.TEID=G.TEID AND GRID=K.KLID";
 
$stmt = OCIParse($conn, $sql);
 
OCIExecute($stmt);
 
$rows = OCIFetchstatement($stmt,$results);
 
 
$keys = array_keys($results);
 
$table "<table>\n <TR>\n";
  foreach(
$keys as $key)
  {
     
$table .= "  <TH>$key</TH>\n";
  }
 
$table .= " </TR>\n";
  for(
$i=0;$i<$rows;$i++)
  {
     
$table .= " <TR>";
      foreach(
$results as $spalte)
      {
         
$data = $spalte[$i];
         
$table .= "  <TD>$data</TD>";     
      }
     
$table .=" </TR>";
  }
 
$sql = "Select T.TEID, TEDATUM, TEUhrzeit, TEORT, TEBeschreibung, BIID as GRID, BIBezeichnung as Bezeichnung From TTermine T, TGruppetermin G, TBILDUNGSGANG B Where T.TEID=G.TEID AND GRID=B.BIID";
 
$stmt = OCIParse($conn, $sql);
 
OCIExecute($stmt);
 
$rows = OCIFetchstatement($stmt,$results);
  for(
$i=0;$i<$rows;$i++)
  {
     
$table .= " <TR>";
      foreach(
$results as $spalte)
      {
         
$data = $spalte[$i];
         
$table .= "  <TD>$data</TD>";     
      }
     
$table .=" </TR>";
  }
 
$sql = "Select T.TEID, TEDATUM, TEUhrzeit, TEORT, TEBeschreibung, BEID as GRID, BEBezeichnung as Bezeichnung From TTermine T, TGruppetermin G, TBERUFSFELD B Where T.TEID=G.TEID AND GRID=B.BEID";
 
$stmt = OCIParse($conn, $sql);
 
OCIExecute($stmt);
 
$rows = OCIFetchstatement($stmt,$results);
  for(
$i=0;$i<$rows;$i++)
  {
     
$table .= " <TR>";
      foreach(
$results as $spalte)
      {
         
$data = $spalte[$i];
         
$table .= "  <TD>$data</TD>";     
      }
     
$table .=" </TR>";
  }
 
$table .="</TABLE>";
 
/***************************/
  //echo "$table";
  /***************************/
 
$sql = "Select BIID From TBILDUNGSGANG";
 
$stmt = OCIParse($conn, $sql);
 
OCIExecute($stmt);
 
$rows = OCIFetchstatement($stmt,$results);
 
$biid = $results[BIID];
 
$select = "<SELECT NAME=\"biid\">\n";
  foreach(
$biid as $data)
  {
     
$select .= " <OPTION VALUE=\"$data\">$data</OPTION>\n";
  }
 
$select .= "</select>";
 
//echo $select;
 
 
echo <<< HTML
  <HTML>
  <HEAD>
    <TITLE>TERMIN.PHP</TITLE>
  </HEAD>
  <BODY>
    <H1>Willkommen bei Termin.PHP</H1>
    Hier sind alle termine<br>
    $table
    <p>Sie k&ouml;nnen sich Termine von Klassen bestimmter Bildungsga&auml;nge ansehen. Einfach ausw&auml;hlen.</p>
    <form action="$PHP_SELF" method="post">
    $select<br>
    <input type="submit">
    </form>
HTML;

 
$biid = $_POST["biid"];
  if(isset(
$biid))
  {
     
$sql = "Select klid, KlBezeichnung, T.TEID, TEDATUM, TEUHRZEIT, TEORT, TEBeschreibung from Tklasse K, TGruppetermin G, TTermine T where Grid=BIID AND T.TEID=G.TEID AND BIID='$biid'";
     
$stmt = OCIParse($conn, $sql);
     
OCIExecute($stmt);
     
$rows = OCIFetchstatement($stmt,$results);
     
$keys = array_keys($results);
     
$table "<table>\n <TR>\n";
      foreach(
$keys as $key)
      {
         
$table .= "  <TH>$key</TH>\n";
      }
     
$table .= " </TR>\n";
      for(
$i=0;$i<$rows;$i++)
      {
         
$table .= " <TR>";
          foreach(
$results as $spalte)
          {
             
$data = $spalte[$i];
             
$table .= "  <TD>$data</TD>";     
          }
         
$table .=" </TR>";
      }
      if(
$rows>0)
      {
          echo
$table;
      }
  }
  echo
"</BODY>\n</HTML>";
?>
jicurito at hotmail dot com
10-Dec-2003 12:41
regarding egypt note on double quotes, the reason for that behaviour is that Oracle treats things with double quotes as identifiers on a given statement... using single quotes won't provoque mistakes...
egypt at nmt dot edu
15-Oct-2003 02:31
Whereas MySQL doesn't care what kind of quotes are around a LIKE clause, ociexecute gives the error:
    ociexecute(): OCIStmtExecute: ORA-00904: "NM": invalid identifier
for the following.
<?php
$sql 
= "SELECT * FROM addresses "
     
. "WHERE state LIKE \"NM\""// error!
$stmt = ociparse($conn, $sql);
ociexecute($stmt);
?>

it's fine if you just use single quotes:
    . "WHERE state LIKE 'NM'";
but i think it's interesting that ociparse doesn't say anything
kobbe at lausitz dot net
22-Jan-2003 09:43
If you use OCI_DEFAULT and OCIRollback, don't forget that a simple SELECT-statement works with an commit that has also an effect on all previously statements.
Los Olvidados
16-Jan-2003 09:46
Every time you call ociexecute(), the setting for autocommit may change.  If you don't want autocommit on, be sure to use OCI_DEFAULT for every call to ociexecute.
alexander dot zimmer at gmx dot at
19-Sep-2002 05:18
Addition to the posting of cthrall@rocketmail.com (from 06-Sep-2000):

It's true, you can't call OCIBindByName in a loop and bind to an associative array like this:

  foreach ($array as $key => $val)
  {
    OCIBindByName($state, $key, $val, -1);
  }

BUT: You can do it this way:

  foreach ($array as $key => $val)
  {
    OCIBindByName($state, $key, $array[$key], -1);
  }

Background: the command OCIBindByName BINDS a PHP variable to a parameter, not just its current value. Thus, it is up to you to make sure that the variable has the correct value at the very time when OCIExecute is called, not just when OCIBindByName was called! The PHP variable gets evaluated at the point of OCIExecute and not earlier.

This is somewhat more legible than cthrall's solution (but it surely works, too).
jgrosland at buildscape dot com
07-Sep-1999 05:57
There seems to be some interesting behavior when using OCI_DEFAULT as the second parameter to ociexecute...  once the autocommit behavior is turned off for a connection, it remains off for the life of that connection. 
This tends to be a problem when using OCIPLogon, as a SQL statement may remain outstanding over the life of many webpages.

This is most problematic when you're doing an update or insert, and a table remains locked while that connection is waiting for a commit/rollback.  Be sure to explicitly commit or rollback if you use OCI_DEFAULT at any point.
robra at lazarus dot stack dot nl
16-Aug-1999 11:31
To catch what an error was about, I use a piece of PL/SQl instead of just a SELECT. For instance:
<?php
 $query
="BEGIN
                        SELECT user_id INTO :v_user_id FROM rw_users
                        WHERE gebruikersnaam = LOWER(:p_alias);
                        :ERROR := 0;
                            EXCEPTION
                                when others then
                                :ERROR := 1;
                                :SQLCODE := SQLCODE;
                                :SQLERRM := SUBSTR(SQLERRM,0,300);
                        END;   "
;


               
$stmt = OCIParse($conn, $query);

               
/* Output parameters */
               
OCIBindByName($stmt,":ERROR",&$insert_error,32);
               
OCIBindByName($stmt,":SQLCODE",&$SQLCODE,32);
               
OCIBindByName($stmt,":SQLERRM",&$SQLERRM,300);
               
OCIBindByName($stmt,":v_user_id",&$v_user_id,32);

               
/*  Input parameters */
               
OCIBindByName($stmt,":p_alias", &$p_alias, strlen($p_alias)+2);

               
$exec_result = OCIExecute($stmt,OCI_DEFAULT);
?>
Now if the select causes an exception, it is caught and the error message is stored.

oci_fetch_all> <oci_error
Last updated: Fri, 06 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites