Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2004
    Posts
    78

    Unanswered: Inserting sequence in table

    Hi

    How can the sequence number be reset when ID and DATE combination changes in something like following -

    INSERT into table_name (ID, DATE, LINE_NUMER) values (ID, DATE, SEQUENCE#)

    Ex. the result should look something like this

    ID, DATE, SEQ#
    =====================
    A1, 20-AUG-2006, 1
    A2, 20-AUG-2006, 2
    A3, 20-AUG-2006, 3
    A4, 20-AUG-2006, 4

    A4, 21-AUG-2006, 1
    A5, 21-AUG-2006, 2

    A1, 21-AUG-2006, 1
    A1, 22-AUG-2006, 2
    A1, 23-AUG-2006, 3

    ====================

    Thanks in advance.

    -BS

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Why would you use a sequence for something like that? Simply have a file with the following contents

    ID, DATE, SEQ#
    =====================
    A1, 20-AUG-2006, 1
    A2, 20-AUG-2006, 2
    A3, 20-AUG-2006, 3
    A4, 20-AUG-2006, 4

    A4, 21-AUG-2006, 5
    A5, 21-AUG-2006, 6

    A1, 21-AUG-2006, 7
    A1, 22-AUG-2006, 8
    A1, 23-AUG-2006, 9

    ====================


    What possible reason would you need the sequence number to restart?
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Oct 2004
    Location
    Oklahoma City OK -
    Posts
    122

    unclear example

    Also,

    Code:
    A1, 21-AUG-2006, 1
    A1, 22-AUG-2006, 2
    A1, 23-AUG-2006, 3
    This portion of your example is inconsistent with the previous lines.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,296
    just write a query for specific counting or ordering.
    you don't want to hardcode that anyways.

    sequences are for uniquely identifying a column
    - The_Duck
    you can lead someone to something but they will never learn anything ...

Posting Permissions

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