How to use oracle sequence.nextval in PHP webservice?

We get sequence in asp.net 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?
SudhanshumAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
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.
1
slightwv (䄆 Netminder) Commented:
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.
1
NerdsOfTechTechnology ScientistCommented:
Yes

<?php

// 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');
oci_execute($stid);

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


http://php.net/manual/en/ref.oci8.php
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
slightwv (䄆 Netminder) Commented:
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.
0
NerdsOfTechTechnology ScientistCommented:
PHP code provided for connecting to Oracle database and running author's query. Assist points for helpful comments regarding the connection. Split points.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.