DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: sequence problem urgent

  1. #1
    Join Date
    Sep 2000
    Posts
    305
    Hi Freinds

    I am getting one problem.
    I have a sequence i.e seq_id, When I use that sequence in two columns in a same query it is returning me the same result.

    select seq_id.nextval,seq_id.nextval from dual;

    it is returing me the same result in both the columns. can you please tell me why it is happening?

    its urgent
    Thanks
    Shialendra

  2. #2
    Join Date
    Nov 2000
    Location
    Israel
    Posts
    268
    Hi,
    You must use seq_id.nextval in each statement:

    set serveroutput on;
    declare
    s1 number;
    s2 number;
    begin
    select seq_id.nextval into s1 from dual;
    select seq_id.nextval into s2 from dual;
    dbms_output.put_line(s1);
    dbms_output.put_line(s2);
    end;
    /

    output:
    3
    4

    cheers,
    r.

  3. #3
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    That's normal and expected behaviour.

    Sanjay

  4. #4
    Join Date
    Sep 2000
    Posts
    305
    but why it is like that what is the reason?

    thanks
    Shailendra

  5. #5
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    it´s a variable

    it´s like i declare a variable and do

    select x, x from dual;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width