Caffeinated
Caffeinated

Reputation: 12484

How to obtain only one specific NEXTVAL result in an Oracle query?

In my stored proc, I run a query like soi :

SELECT [email protected] 
FROM [email protected]
WHER PROVID = 28938

How would obtaon only one NEXTVAL result?

Upvotes: 1

Views: 79

Answers (2)

Steven Feuerstein
Steven Feuerstein

Reputation: 1974

Or more generally: make sure your FROM and WHERE clauses result in just one row found - then NEXTVAL will be executed just once.

In addition, you can always get just a single NEXTVAL execution by invoking it natively in PL/SQL, as in:

DECLARE
   l_seq INTEGER;
BEGIN
   l_seq := my_sequence.NEXTVAL;
END;

Upvotes: 4

Lukasz Szozda
Lukasz Szozda

Reputation: 175706

Using dual:

SELECT [email protected] FROM dual

Upvotes: 5

Related Questions