[EMAIL PROTECTED] wrote:
In Oracle you would write: insert into pts (pid, txt) values (1,'502a');
But in PHP you are going to do the following:
$conn = oci_connect('scott','tiger','my_db');
$sql = "insert into pts (pid, txt) values (1,'502a')";
$cursor = oci_parse($conn, $sql);
if (! $cursor)
{ $err = oci_error($conn);
print htmlentities($e['message']);
exit;
}
$results = oci_execute($cursor);
oci_commit($conn);
oci_close($conn);
The statements:
$results = oci_execute($cursor);
oci_commit($conn);
do two commits. Oci_execute() commits by default. The message
to the database to perform the commit is "piggybacked" in the
execute call. However the subsequent (unecessary in this case)
oci_commit() call requires an explicit round trip to the DB.
If you were doing multiple inserts you might do something like:
$s = oci_parse($c, 'insert into ptab (pdata) values (:bv)');
oci_bind_by_name($s, ':bv', $v, 20, SQLT_CHR);
foreach ($a as $v) {
$r = oci_execute($s, OCI_DEFAULT);
}
oci_commit($c);
Or explore calling a PL/SQL block and do a bulk FORALL insert.
I'll blog about bulk FORALL in a few days.
Chris
--
Christopher Jones, Oracle
Email: [EMAIL PROTECTED] Tel: +1 650 506 8630
Blog: http://blogs.oracle.com/opal/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php