note 77462 modified in function.ocinewdescriptor by sixd
| From: | sixd@php.net | Date: | Thu, 08 Oct 2009 19:27:41 +0000 |
| Subject: | note 77462 modified in function.ocinewdescriptor by sixd | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161552@lists.php.net to get a copy of this message | ||
If you just want to retrieve an auto-increment field like an integer, you don't have to use the
oci_new_descriptor function:
$dbh = ociplogon("username","pw","sid");
$query = "INSERT INTO employees (name) VALUES ('Jones') RETURNING employee_no INTO
:employee_no";
$stmt = oci_parse($dbh, $query);
// oci_new_descriptor not necessary...
// Bind the variable to the parsed statement.
// I used '8' as the minimum length - otherwise it was setting the default length to
'1', so when an employee_no like 18366 was returned, the variable would be set to
'1' (the first digit), so make sure you set a length.
oci_bind_by_name($stmt, ":employee_no", $employee_no, 8);
oci_execute($stmt, OCI_DEFAULT);
// Commit the change
oci_commit($dbh);
// Free resources associated with the statement
oci_free_statement($stmt);
print "new employee no is: $employee_no";
--was--
If you just want to retrieve an auto-increment field like an integer, you don't have to use the
oci_new_descriptor function:
$dbh = ociplogon("username","pw","sid");
$query = "INSERT INTO employees (name) VALUES ('Jones') RETURNING employee_no INTO
:employee_no";
$stmt = oci_parse($dbh, $query);
// oci_new_descriptor not necessary...
// Bind the variable to the parsed statement.
// I used '8' as the minimum length - otherwise it was setting the default length to
'1', so when an employee_no like 18366 was returned, the variable would be set to
'1' (the first digit), so make sure you set a length.
oci_bind_by_name($stmt, ":employee_no", $employee_no, 8);
oci_execute($stmt, OCI_DEFAULT);
// Commit the change
oci_commit($dbh);
// Free resources associated with the statement
oci_free_statement($stmt);
print "new employee no is: $employee_no";
http://php.net/manual/en/function.ocinewdescriptor.php