Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: getting NEXTVAL from User_sequences vs Dual

Re: getting NEXTVAL from User_sequences vs Dual

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Wed, 08 Jul 1998 19:28:11 GMT
Message-ID: <35a8c765.23714119@192.86.155.100>


A copy of this was sent to markag_at_my-dejanews.com (if that email address didn't require changing) On Wed, 08 Jul 1998 18:01:27 GMT, you wrote:

>I'm curious as to why some of the existing code I'm working on retrieves the
>nextval for sequences through user_sequences instead of dual; example:
>
>"SELECT SEQ_CUST_ID.NextVal from USER_SEQUENCES"
>
>vs
>
>"SELECT SEQ_CUST_ID.NextVal from DUAL"
>
>I notice that when you retrieve from user_sequences, your nextval is
>incremented by the number of sequences within that schema times the increment
>value of the sequence, but when retrieved through DUAL, it is always the
>increment value. Is this because there is only one row in dual, and
>potentially many rows in user_sequences?
>

thats exactly right -- dual has one row, hence select seqname.nextval from dual increments by 1. user_sequences has a row per sequence the current user owns (or if called from a stored procedure the number of rows the owner of the procedure can see in user_sequences) and will increment the sequence by that amount.

they probably didn't understand dual -- I would change the query to be from dual instead of user_sequences...

>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Wed Jul 08 1998 - 14:28:11 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US