Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    6

    Question Unanswered: How do i get seq.nextval from within a pl/sql function

    Hi,

    Im using Oracle 9i and writing a PL/SQL function and i need to get the sequence.nextval within the function. I am getting an error saying sequence does not exist. I have tryed the following :

    select mySeq.nextval
    into v_myvar
    from dual;

    but I still get the same error message. Is there any way to get the next value in a sequence from within a PL/SQL function.

    Any help would be greatly appreciated.
    Thanks

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    PHP Code:
    CREATE SEQUENCE myseq;

    CREATE OR REPLACE FUNCTION fun_seq
       
    RETURN NUMBER
    AS
       
    retval   NUMBER;
    BEGIN
       SELECT myseq
    .NEXTVAL
         INTO retval
         FROM DUAL
    ;

       RETURN (
    retval);
    END;
    /

    SELECT fun_seq FROM DUAL;

    FUN_SEQ
    -------
          


  3. #3
    Join Date
    Feb 2004
    Posts
    6
    Hi,
    Thanks. I dont need to create a sequence because the sequence that I am using (mySeq) already exists on the database.

    Thanks

  4. #4
    Join Date
    Feb 2004
    Posts
    6
    Figured it out. It was a permissions issue.

Posting Permissions

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