Home » Open Source » Programming Interfaces » PHP-Oracle getting inserted rowID (PHP 5.X Oracle10g)
PHP-Oracle getting inserted rowID [message #502449] Wed, 06 April 2011 06:59 Go to next message
mrmcs
Messages: 1
Registered: April 2011
Junior Member
Im using Oracle 10g and PHP5.x

on Data insert in return i need CUST_NO ID which is auto generated in database


<?php
if ($conn = oci_connect('scott','tiger', '192.168.0.225/XE')) {


$insert = "Insert into CUST (STORE_Name,CUST_TYPE_NO) values ('my store',2)";
$cursor = oci_parse($conn, $insert);
oci_execute($cursor);


oci_close($conn);
}
else
{
$err = oci_error();
echo "Oracle Connect Error " . $err['text'];
}
?>

-----------------------------------
My table structure is


Column Name Data Type Nullable Default Primary Key
CUST_NO NUMBER No - 1
STORE_Name Varchar2(25) No - -
CUST_TYPE_NO NUMBER No - -



Re: PHP-Oracle getting inserted rowID [message #502452 is a reply to message #502449] Wed, 06 April 2011 07:17 Go to previous message
Michel Cadot
Messages: 59791
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
There is no auto number/increment/generated column in Oracle, you must ensure that you have a trigger on the table that fills the id.

Have a look at the numerous solution there:
http://www.google.com/search?hl=en&source=hp&q=oracle+auto_increment

Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.

Regards
Michel
Previous Topic: Python and Array of CLOBs using cx_Oracle
Next Topic: Permission of Perl/Library
Goto Forum:
  


Current Time: Wed Nov 26 13:09:00 CST 2014

Total time taken to generate the page: 0.19637 seconds