Inserta una fila, y luego imprime todas las filas de la tabla

<?php

$username="EIA";
$password="EIA";
$host="192.168.0.1";
$port="1521";
$sid="ORCL";
$table="hidro";
$cstr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$host)(PORT=$port))
                        (CONNECT_DATA=(SID=$sid)))";

$conn = OCILogon($username, $password, $cstr);
if (!$conn) {
  $e = oci_error();
  print htmlentities($e['message']);
  exit;
}

$query = "INSERT INTO HIDRO VALUES (17, 'nose', 'commit')";
$stid = oci_parse($conn, $query);
if (!$stid) {
  $e = oci_error($conn);
  print htmlentities($e['message']);
  exit;
}

$r = oci_execute($stid, OCI_COMMIT_ON_SUCCESS);
if (!$r) {
  $e = oci_error($stid);
  echo htmlentities($e['message']);
  exit;
}


$query = 'SELECT * FROM HIDRO';
$stid = oci_parse($conn, $query);
if (!$stid) {
  $e = oci_error($conn);
  print htmlentities($e['message']);
  exit;
}

$r = oci_execute($stid);
if (!$r) {
  $e = oci_error($stid);
  echo htmlentities($e['message']);
  exit;
}

print '<table border="1">';
while ($row = oci_fetch_assoc($stid)) {
  print '<tr>';
  foreach ($row as $item) {
    print '<td>'.($item?htmlentities($item):'&nbsp;').'</td>';
  }
  print '</tr>';
}
print '</table>';

oci_close($conn);

?>

Php/Codigo/Oracle (last edited 2010-10-12 16:27:24 by Kmilo)