1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Get seq.nextvalue for future usage

Discussion in 'General' started by cedico, Dec 27, 2016.

  1. cedico

    cedico Starter

    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    10
    Location:
    PARIS
    Hi,

    I need to create a file which name contains the unique sequence nextvalue (ex : "myfile-20161223-15) where 15 is the sequence value of the TABLE which will reference the file.
    Then I need to create a ROW in a table to save my file location :

    ID | FILENAME (ID is the primary key)
    15 | myfile-20161223-15

    Is it safe and a good way to get the NEXTVALUE (without executing the INSERT immediatly) and then later, to INSERT the ROW using the unique value reserved ?
    I execute the INSERT only after having created the file, and use the sequence value to store the unique ID

    Regards
     
  2. Yasin Musani

    Yasin Musani Active Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    55
    Location:
    India
    Hello cedico,

    In PL/SQL generally, Sequence is used for generating the unique number for the primary key column, It doesn't matter you used with insert statement or used before insert statement.
     
  3. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,645
    Likes Received:
    372
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Please read here:

    https://dfitzjarrell.wordpress.com/2008/06/06/out-of-sequence/

    it should answer your question.
     
  4. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,645
    Likes Received:
    372
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Which is nice to know but it doesn't answer the original question; the link I posted will.