New PL/SQL Feature in Oracle 11g: the use of sequence.nextval

0 0
Read Time:25 Second

Another small new feature in Oracle 11g PL/SQL: you can directly use sequence.nextval (and sequence.currval). It is not necessary anymore to do something like select sequence.nextval into l_seq from dual in your PL/SQL block. A small example: 

declare
  l_seq number;
begin
  l_seq := oe.orders_seq.nextval;
  dbms_output.put_line('Value of orders_seq.nextval = '||to_char(l_seq));
end;

SQL>

Value of orders_seq.nextval = 1000

PL/SQL-procedure is geslaagd.

About Post Author

Jurgen Kemmelings

Oracle consultant at AMIS
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

4 thoughts on “New PL/SQL Feature in Oracle 11g: the use of sequence.nextval

  1. Hi,
    i assume that ‘l_seq := oe.orders_seq.nextval;’ is translated/executed internally to ‘SELECT oe.orders_seq.nextval INTO l_seq FROM DUAL;’
    did you trace it?

    Karl

  2. This is another small but good step in the right direction. I tried if it was possible to assign a sequence to the default expression of a column, but it appears this feature is really restricted to PL/SQL.
    As I see it now, many features are small tweaks to pl/sql.

Comments are closed.

Next Post

Building a report in XML Publisher

Last week I made my first steps with XML-Publisher 5.6 Desktop and I am very pleased with the simplicity you can create a report in such a short time. When you follow these instructions you can see it yourself. After you have installed the XML-Publisher 5.6 Desktop you open Microsoft Word […]
%d bloggers like this: