How to use oracle sequence.nextval in PHP  webservice?

Sudhanshum used Ask the Experts™
We get sequence in using query "select seq.nextval from dual" but i want to use that in PHP webservice  also,is it possible to use oracle sequence in PHP webservice? Can you help me on that?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013
I don't know Oracle, but an SQL statement for a given database is going to be the same in any server side language because you are assigning the sql statement to a variable that gets passed to your server side code which accesses the db and sends the sql statement to the db for a response.
Most Valuable Expert 2012
Distinguished Expert 2018
If the PHP web service performs DML at the database, just add seq.nextval to the DML statement.

Unless we see the actual code that is pretty much all I can offer.
Technology Scientist


// Connects to the XE service (i.e. database) on the "localhost" machine
$conn = oci_connect('hr', 'welcome', 'localhost/XE');
if (!$conn) {
    $e = oci_error();
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);

$stid = oci_parse($conn, 'select seq.nextval from dual');

echo "<table border='1'>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
    echo "<tr>\n";
    foreach ($row as $item) {
        echo "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
    echo "</tr>\n";
echo "</table>\n";


Open in new window
Most Valuable Expert 2012
Distinguished Expert 2018
Unless you need the next sequence value in several places outside of the database, I would never make a round trip to the database just to get one.
NerdsOfTechTechnology Scientist

PHP code provided for connecting to Oracle database and running author's query. Assist points for helpful comments regarding the connection. Split points.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial