Generate a sequence

Hi all,
I was wondering if you can help me here.
I am new to Oracle (having come from a SQL Server background) and I need to generate sequence numbers using a function.
This is the scenario
we have a table called APPS_CODES with columns CODE, VALUE
The values in this table are
213, Y
214, Y
215,N
We also have another table called SETCODES columns (ID, DESC)
values in this table are
2,AIR
3,BUS
4, TRAIN
Finally we have a sequence as follows
min value 1, maxvalue 9999999 cycle
Now what we require is a function that produces an id in the form
21320000001 to 21329999999.
this is how it needs to be generated:
It needs to select the min(CODE) from the APPS_CODE table where value=Y then concatenate this with the ID from set codes table where DESC=AIR then concatenate this with the sequence. The sequence should be left padded with 0s so as to start from 0000001.
Once the sequence reaches 9999999 then the APPS_CODE table needs to be updated and the current code should now have its value set to N so we can start using the next CODE where value=Y.
So when we reach 21329999999 the next value returned by the fucntion will be 21420000001 uptil 21229999999
Any help will be appreciated
thanks alot

I have created the function which seems to work fine.
However when it gets to the 3 record it fails with the following error message
GEN3
2674040000001
Elapsed: 00:00:00.00
15:59:15 test@CAMDEVF8> /
GEN3
2674040000002
Elapsed: 00:00:00.00
16:03:45 test@CAMDEVF8> /
select gen3 from dual
ERROR at line 1:
ORA-00904: "N3_V": invalid identifier
ORA-06512: at "TUNDE.GEN3", line 15
Any help.
Fucntion is below
Thanks
Create or replace
Function gen3
RETURN VARCHAR2 IS
l_v VARCHAR2(30);
n_v INTEGER;
n2_v VARCHAR2(30);
n3_v NUMBER;
BEGIN
     SELECT gen2.NEXTVAL INTO n_v
     FROM dual;
     SELECT value INTO n2_v FROM config_settings
     WHERE KEY='Airline Code';
     SELECT MIN(form_code) INTO n3_v FROM form_codes WHERE doc_type='EMCO' AND available='Y';
     l_v:=n2_v||n3_v||lpad(n_v,7,'0');     
     IF n_v=3
     THEN
     EXECUTE IMMEDIATE 'UPDATE form_codes SET available=''N'' WHERE form_code = n3_v;
     commit;
          END IF;
     RETURN l_v;
END gen3;
--grant execute on generate_document_number to cam_cust_role;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Select from table in group of columns and generate a sequence number

    I have to select data from a table in group of columns and generate a sequence for every group resetting the sequence to start from 1 onwards.
    For example:
    Data:
    Col1 Col2 Col3 Col4
    A NA KA 2009-08-13
    B NA KA 2009-08-13
    C NA KA 2009-08-13
    A NA KA 2009-08-13
    B NA KA 2009-08-13
    A NA KA 2009-08-13
    Expected output from Select Statement:
    Col1 Col2 Col3 Col4 Seq_No
    A NA KA 2009-08-13 1
    A NA KA 2009-08-13 2
    A NA KA 2009-08-13 3
    B NA KA 2009-08-13 1
    B NA KA 2009-08-13 2
    C NA KA 2009-08-13 1
    How can this be possible with a SELECT statement? Is it possible to assign seq numbers for a group of columns and reset it when it changes? In the above example, all columns form the key to generate the seq number
    I know it can be done using Stored procedures and that is how I am doing it now by introducing a temporary table.
    Can anyone help me in this regard? Please let me know if the question is vague to understand!
    Thanks,
    Nachi

    with t as(select 'A' col1,'NA' col2 ,'KA' col3,'2009-08-13' col4 from dual
    union all
    select 'B' col1,'NA' col2 ,'KA' col3,'2009-08-13' col4 from dual
    union all
    select 'C' col1,'NA' col2 ,'KA' col3,'2009-08-13' col4 from dual
    union all
    select 'A' col1,'NA' col2 ,'KA' col3,'2009-08-13' col4 from dual
    union all
    select 'B' col1,'NA' col2 ,'KA' col3,'2009-08-13' col4 from dual
    union all
    select 'A' col1,'NA' col2 ,'KA' col3,'2009-08-13' col4 from dual)
    select t.*,row_number() over (partition by col1,col2,col3,col4 order by col1,col2,col3,col4) from tYou can replace partition by col1,col2,col3,col4 with only columns that you need for grouping condition
    and also order by you can just do on the column you need.

  • Generate a sequence of number

    Hi i am using
    select rownum rn from user_objects where rownum <= 20;
    to generate a sequence of number....
    is there any other better way...???

    try
    select level
    from dual
    connect by level <= 20;
    illustrated at -
    http://nimishgarg.blogspot.com/2010/01/oracle-sql-get-all-month-names-jan-to.html

  • Generating a sequence of waveforms with NI 5640R card

    Hello,
    I have a question regarding generating a sequence of waveforms. I want to use the example "NI 5640R analog input and output" (I know this example is capable of generating a QAM or single tone signal) and make changes such that the when i run the VI i want the output to be switching between single tone and QAM and i want this to happen until i stop the VI.
    And in the future i want to add another waveform (sawtooth) and want my output to be switching between the 3 waveforms. Any help regarding this will be grately appreciated.
    Thanks,
    Sandeep. 
    Sandeep Palreddy, Graduate Research Assistance
    The Microwave Remote Sensing Laboratory (MIRSL)
    University of Massachusetts
    151 Holdsworth Way
    Amherst MA 01003-9284

    Hello,
    I have a question regarding generating a sequence of waveforms. I want to use the example "NI 5640R analog input and output" (I know this example is capable of generating a QAM or single tone signal) and make changes such that the when i run the VI i want the output to be switching between single tone and QAM and i want this to happen until i stop the VI.
    And in the future i want to add another waveform (sawtooth) and want my output to be switching between the 3 waveforms. Any help regarding this will be grately appreciated.
    Thanks,
    Sandeep. 
    Sandeep Palreddy, Graduate Research Assistance
    The Microwave Remote Sensing Laboratory (MIRSL)
    University of Massachusetts
    151 Holdsworth Way
    Amherst MA 01003-9284

  • Need SQL statement to generate a sequence number in the output rows

    Hi folks. I need to create an SQL statement that generates a sequence number column in the output rows (records) such that the first returned row has this column set to 1, second returned row has the column set to 2, etc.
    For example, consider the query:
    SELECT income from employees WHERE income != 20000 ORDER BY income;
    If employees.income contains 60,000, 20,000, 35,000, and 19,000 for respective rows, the output would be this:
    19,000
    35,000
    60,000
    I would like the SQL to also return a sequence number that is computed across the returned rows, resulting in two output columns:
    1 19,000
    2 35,000
    3 60,000
    Is there a simple SQL function that generates the sequence number, in order, and only for the returned rows? Or is there another way?
    I'm stumped. Any help is appreciated! Thanks!
    - Jack Cochrane

    Hi,
    Welcome to the forum!
    Use ROWNUM, like (example):
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL> select rownum, first_name from (select e.first_name from employees e where e.first_name like 'J%' order by e.first_name);
        ROWNUM FIRST_NAME
             1 Jack
             2 James
             3 James
             4 Janette
             5 Jason
             6 Jean
             7 Jennifer
             8 Jennifer
             9 John
            10 John
            11 John
            12 Jonathon
            13 Jose Manuel
            14 Joshua
            15 Julia
            16 Julia
    16 rows selected
    SQL> But rememeber if you want to be sure of unique numbers in certain field is better to use sequences and use seq_name.nextval each time you need.
    Regards,

  • Calculate date differences in consecutive rows and generate a sequence

    Hi Guys,
    I am trying to implement one scenario where in i need to compare the date differences for consecutive rows and generate a sequence against that.
    this is the table schema:
    create table temp
    id int identity(1,1),
    emp_id int,
    time datetime
    insert into temp 
    values
    (1, '2011-02-20 12:30:00.000'),
    (1, '2011-02-20 12:32:34.172'),
    (1, '2011-02-20 12:32:34.172'),
    (1, '2011-02-20 12:43:21.004'),
    (1, '2011-02-20 12:46:39.745'),
    (2, '2011-02-20 12:48:06.004'),
    (2, '2011-02-20 12:48:06.004'),
    (2, '2011-02-20 12:53:07.733'),
    (2, '2011-02-20 12:55:30.295');
    now, I want to compare the first date-time with the second and so on. now if the date-time difference is same for two consecutive rows then the sequence should  increment by 1 otherwise the sequence again will start from '00' for any unique date-time.
    This sequence number should start from '00' from each employee.
    I want the output to be like this
    ID emp_id
    time    
    sequence
    1 1 2011-02-20 12:30:00.000
    00
    2  1 2011-02-20 12:32:34.172
    00
    3  1 2011-02-20 12:32:34.172
    01
    4  1 2011-02-20 12:32:34.172
    02
    5  1 2011-02-20 12:46:39.745
    00
    6  2 
    2011-02-20 12:48:06.004 00
    7  2 
    2011-02-20 12:48:07.003 00
    8  2 
    2011-02-20 12:48:07.003 01
    9  2 
    2011-02-20 12:46:39.745 00
    Please revert as soon as possible as this is a bit urgent.
    Thank You in Advance. :)

    create table temp
    (id int identity(1,1),
     emp_id int,
     time datetime
    insert into temp values
    (1, '20110220 12:30:00.000'),
    (1, '20110220 12:32:34.172'),
    (1, '20110220 12:32:34.172'),
    (1, '20110220 12:43:21.004'),
    (1, '20110220 12:46:39.745'),
    (2, '20110220 12:48:06.004'),
    (2, '20110220 12:48:06.004'),
    (2, '20110220 12:53:07.733'),
    (2, '20110220 12:55:30.295');
    go
    SELECT id, emp_id, time,
           dateadd(mcs, (row_number() OVER(PARTITION BY emp_id, time ORDER BY
    id) - 1) * 10,
                   convert(datetime2(5), time)) AS [Sequence]
    FROM   temp
    ORDER  BY id
    go
    DROP TABLE temp
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Unsupported generator type: SEQUENCE

    Is the primary key generation strategy "SEQUENCE" supported? I have an entity, based on a table in Oracle database, whose primary key is generated by a sequence in Oracle database. When I deploy the entity I get the following error...
    ORPersistence Model Builder: Exception occurred: com.sap.engine.services.orpersistence.model.ormappingmodel.ORMException: Unsupported generator type: SEQUENCE at com.sap.engine.services.orpersistence.model.ormappingmodel.impl.ORMappingModelCreatorImpl.parseId(ORMappingModelCreatorImpl.java:2347), file: EntityTest.jar, column 0, line 0, severity: error

    Hi Christopher,
    The generation types SEQUENCE and IDENTITY are currently not supported by the JPA implementation in this release. You can however use the TABLE and AUTO generation types. In the case of AUTO you have to provide a table TMP_SEQUENCE created like this:
    CREATE TABLE "TMP_SEQUENCE"
    "GEN_KEY" VARCHAR(256) UNICODE NOT NULL,
    "GEN_VALUE" INTEGER,
    PRIMARY KEY ("GEN_KEY")
    HTH!
    -Vladimir

  • "How do I generate a sequence of waveforms, like first a sine wave, then a square one, and say again a sine wave?"

    "Hello everyone, I hope someone can answer the following question. How do I generate a sequence of different waveforms, with different attributes?
    Like, i want to generate a sine wave for some time, then a square pulse of some width and then again a sine wave of some other time. Finally I want to repeat this sequence. I'll really appreciated it if I can get an answer soon. Thank you!

    From the previous comments I am assuming that your waveforms are arrays, rather than the waveform data type. I am also assuming that the sine waves on both sides of the square wave are the same signal.
    If so then I suggest a slightly different approach. 1. Generate your sine wave, rather than the empty array. The length should be the length of the entire end signal.
    2. Generate the square waveform. You can either generate it at the length you need, or you can generate a much larger square wave, and then use the Array Subset VI to get the portion you need. Which method you use depends how you want to implement the whole method.
    3. Use the Replace Array Subset VI to place the portion of the square wave at the location (index) of the original sine wave you ge
    nerated.
    The result of this method will be an array that starts with your sine wave, and then at the index you choose it will place the square wave of the length you want right into the signal, and then finish up with the sine wave for the rest of the signal.
    Evan Collier
    Application Engineering
    National Instruments

  • How to generate random sequence numbers

    Hello experts
    Iu2019m writing a custom program and pulling data from VBAK & VBAP. As per requirement I also need to generate a sequence number randomly and finally store all data in text file and upload at server. The hiccup is I donu2019t know how to generate sequence numbers. Can somebody please show me how I can accomplish it?
    Thanks a lot in advance

    Find the below code,
      data: lv_range type datatype-char0128.
      call function 'RANDOM_C'
        exporting
          len_min   = 20
          len_max   = 20
          char_min  = 1
          char_max  = 20
        importing
          rnd_value = lv_range.
    LV_RANGE param will have a random value..
    If you need number you can use the FM "RANDOM_I4"
    Thanks,
    Prathap

  • Generate alphanumeric sequence using oracle sequence

    Hi,
    Can we generate alphanumeric sequence from Oracle sequence.
    Sequence would be something like this. Please advice
    TEMP-0001
    TEMP-0002
    TEMP-0010
    Thanks,
    Lak

    hi,
    You can try below procedure...
    SQL> create sequence sec
      2  minvalue 0
      3  start with 001
      4  increment by 1
      5  nocache;
    Sequence created.
    SQL> select 'temp-'||to_char(sec.nextval) from dual;
    'TEMP-'||TO_CHAR(SEC.NEXTVAL)
    temp-1

  • Generate a sequence with a PCI DIO 32HS

    I'm using a C compiler and i'm working on a DAQ product PCIDIO32HS (653X).
    I want to generate a logic sequence (1,0,0,1...) in burst mode with an internal clock (PCLK) and send it on a line or a port. (Output)
    I tried many examples and many configurations and i didn't success.
    If someone have C code that could help me ?

    Greetings,
    Have you tried the example DOsingleBufBurstHandshake653x.C?
    It should be installed in the following location:
    C:\Program Files\National Instruments\NI-DAQ\Examples\VisualC\Do
    It appears to meet all of your criteria. Good luck with your application.
    Spencer S.

  • Generating a sequence of numbers

    Hi there, I'm trying to generate a number sequence. The description is as follows:
    a)1 is in the sequence
    b) If number X is in the sequence then so are the numbers 3*X, 5*X, and 7*X.
    c) No number appears more than once in the sequence, and
    d) No other number is in the sequence.
    Thus, first few numbers in the sequence are:
    1,3,5,7,9,15,21,25,27,35,45,49,63,75,81,105...
    I need to print out the first 1000 elements of this sequence which is fairly large.
    How can i compute this sequence and print the first 1000 elements of this sequence? I think that we need 3 separate methods, 1 for 3*X, 5*X and 7*X. Can anyone out there help me with this?

    The following code is in ML (because that's what I did this in for an exercise in my first year). datatype stream = Item of int * (unit->stream);
    fun cons (x,xs) = Item (x,xs);
    fun head (Item(i,xf))=i;
    fun tail (Item(i,xf))=xf();
    fun maps f xs = cons(f (head xs), fn()=> maps f (tail xs));
    fun merge (xs,ys)=
        let val x = head (xs);
            val y = head (ys)
        in if x=y then cons(x, fn()=>merge((tail(xs)), (tail (ys))) )
           else if x<y then cons(x, fn()=>merge((tail(xs)), ys) )
                else cons(y, fn()=>merge(xs,(tail(ys))) ) end; (* y<x *)
    fun merge3(xs,ys,zs) = merge(xs,merge(ys,zs));
    fun threefiveseven()=
        cons(1, fn()=>
             merge3( maps (fn x=> 3*x) (threefiveseven()),
                     maps (fn x=> 5*x) (threefiveseven()),
                     maps (fn x=> 7*x) (threefiveseven()) )); Translating into Java elegantly isn't easy, because Java doesn't have function pointers. It took me quite a while, because it's difficult to avoid infinite recursion. (That's what the unit->stream and fn()=> is all about). Here you go: abstract class Function
        abstract int f(int i);
    class Maps extends Stream
        Function f;
        Maps(Function f, Stream xs)
            this.head = f.f(xs.head());
            this.tail = xs;
            this.f = f;
        Stream tail()
            return new Maps(f, tail.tail());
    class Merge extends Stream
        Stream xs;
        boolean tailxs;
        Stream ys;
        boolean tailys;
        Merge(Stream xs, Stream ys)
            int x = xs.head();
            int y = ys.head();
            this.xs = xs;
            this.ys = ys;
            if (x == y)
                head = x;
                tailxs = true;
                tailys = true;
            else if (x < y)
                head = x;
                tailxs = true;
                tailys = false;
            else
                head = y;
                tailxs = false;
                tailys = true;
        Stream tail()
            Stream left = (tailxs) ? xs.tail() : xs;
            Stream right = (tailys) ? ys.tail() : ys;
            return new Merge(left, right);
    abstract class Stream
        int head;
        int head() { return head; }
        Stream tail;
        abstract Stream tail();
    public class Test
        public static void main(String[] args)
            printFirst(new ThreeFiveSeven(), 10);
        static void printFirst(Stream stream, int n)
            while(n-- > 0)
                System.out.println(stream.head());
                stream = stream.tail();
    class ThreeFiveSeven extends Stream
        ThreeFiveSeven()
            head = 1;
        Stream tail()
            Stream three = new Maps(new Times3(), new ThreeFiveSeven());
            Stream five = new Maps(new Times5(), new ThreeFiveSeven());
            Stream seven = new Maps(new Times7(), new ThreeFiveSeven());
            return new Merge(three, new Merge(five, seven));
    class Times3 extends Function
        int f(int i) { return 3 * i; }
    class Times5 extends Function
        int f(int i) { return 5 * i; }
    class Times7 extends Function
        int f(int i) { return 7 * i; }
    }

  • How to generate PN sequence?

    Thank you in advance.
    Now I'm converting Matlab codes into a LabVIEW code. While doing it, I don't know how to generate a PN sequence that I generated on Matlab using 'commsrc.pn' or 'seqgen.pn' function. I searched some threads, and found out that the Binary MLS VI can generate it, but I'm not sure it will generate the same sequence or not. Can anyone help me with this?

    Does the PN sequence need to follow a particular distribution or constrain?  
    Kudos and Accepted as Solution are welcome!

  • How I can change this query to generate a sequence

    This query
    select
    SZSTCLA_PIDM,
      SZSTCLA_TERM_CODE,
      SZSTCLA_LAST_NAME
      from SZSTCLA,SHRTGPA
    where SZSTCLA_PIDM IN ( 120125,186114)
    AND SHRTGPA_TERM_CODE = SZSTCLA_TERM_CODE
    AND  shrtgpa_pidm  = SZSTCLA_PIDM
      AND SZSTCLA_RECORDED_EARNED_CRED > 0
      ORDER BY SZSTCLA_TERM_CODE returns the following results
    SZSTCLA_PIDM     SZSTCLA_TERM_CODE      SZSTCLA_LAST_NAME
    186114     198810     Johnson
    186114     198820     Johnson
    186114     198910     Johnson
    186114     198920     Johnson
    186114     199010     Johnson
    186114     199020     Johnson
    186114     199110     Johnson
    186114     199120     Johnson
    120125     200720     Smith
    120125     200810     Smith
    120125     200820     Smith
    120125     200910     Smith
    120125     200920     Smith
    120125     201010     Smith
    120125     201020     Smith
    120125     201110     Smith
    120125     201120     SmithNotice that breaks in every szstcla_pidm, I need to modify the query, so it can display a number sequence for each SZSTCLA_TERM_CODE
    so it will be like
    SZSTCLA_PIDM     SZSTCLA_TERM_CODE      SZSTCLA_LAST_NAME                                    seq
    186114                     198810                                     Johnson                         1
    186114                     198820                                     Johnson                         2
    186114                    198910                                     Johnson                         3
    186114                    198920                                     Johnson                         4
    186114                    199010                                     Johnson                         5
    186114                    199020                                     Johnson                         6
    186114                    199110                                     Johnson                         7
    186114                    199120                                     Johnson                         8 then
    SZSTCLA_PIDM     SZSTCLA_TERM_CODE      SZSTCLA_LAST_NAME                                      seq
    120125                  200720                                   Smith                             1
    120125                  200810                                    Smith                             2
    120125                  200820                                   Smith                              3
    120125                  200910                                   Smith                              4
    120125                  200920                                   Smith                              5
    120125                  201010                                   Smith                              6
    120125                  201020                                   Smith                              7
    120125                  201110                                   Smith                              8
    120125                  201120                                   Smith                              9

    here are the insert scripts,I slighthly change the name of the tables(the tables are already in the DB)
    create table SZSTCLT
    SZSTCLT_PIDM NUMBER(8),
    SZSTCLT_TERM_CODE VARCHAR2(8),
    SZSTCLT_LAST_NAME VARCHAR2(30)
    create table SHRTGPT
    SHRTGPT_PIDM NUMBER(8),
    SHRTGPT_TERM_CODE VARCHAR2(8)
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '198810','Johnson' FROM DUAL;   
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '198820','Johnson' FROM DUAL;   
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '198910','Johnson' FROM DUAL;   
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '198920','Johnson' FROM DUAL;   
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '199010','Johnson' FROM DUAL; 
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '199020','Johnson' FROM DUAL;  
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '199110','Johnson' FROM DUAL;
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 186114, '199120','Johnson' FROM DUAL;
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 120125,'200920','Smith' FROM DUAL;
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 120125,'201010','Smith' FROM DUAL;
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 120125,'201020','Smith' FROM DUAL;
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 120125,'201110','Smith' FROM DUAL;
    INSERT INTO SZSTCLT( SZSTCLT_PIDM, SZSTCLT_TERM_CODE,SZSTCLT_LAST_NAME) SELECT 120125,'201120','Smith' FROM DUAL;
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 120125, '200920' FROM DUAL;
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 120125, '201010' FROM DUAL;
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 120125, '201020' FROM DUAL;
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 120125, '201110' FROM DUAL;
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 120125, '201120' FROM DUAL;
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '198810' FROM DUAL; 
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '198820' FROM DUAL;  
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '198910' FROM DUAL;    
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '198920' FROM DUAL;    
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '199010' FROM DUAL;  
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '199020' FROM DUAL; 
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '199110' FROM DUAL; 
    INSERT INTO SHRTGPT(SHRTGPT_PIDM,SHRTGPT_TERM_CODE) SELECT 186114, '199120' FROM DUAL;   This query
    select
    SZSTCLT_PIDM,
      SZSTCLT_TERM_CODE,
      SZSTCLT_LAST_NAME,
      row_number() over (partition by  SZSTCLT_PIDM, SZSTCLT_TERM_CODE order by  SZSTCLT_PIDM,SZSTCLT_TERM_CODE)   seq
      from SZSTCLT,SHRTGPT
    where SZSTCLT_PIDM IN ( 120125,186114)
    AND SHRTGPT_TERM_CODE = SZSTCLT_TERM_CODE
    AND  SHRTGPT_PIDM  = SZSTCLT_PIDM
    -- AND SZSTCLA_RECORDED_EARNED_CRED > 0
    ORDER BY SZSTCLT_PIDM,SZSTCLT_TERM_CODE is generating this output
    120125     201020     Smith     1
    120125     201110     Smith     1
    120125     201120     Smith     1
    186114     198810     Johnson     1
    186114     198820     Johnson     1
    186114     198910     Johnson     1
    186114     198920     Johnson     1
    186114     199010     Johnson     1
    186114     199020     Johnson     1
    186114     199110     Johnson     1
    186114     199120     Johnson     1 I want something like this
    120125     201020     Smith     1
    120125     201110     Smith     2
    120125     201120     Smith     3
    186114     198810     Johnson     1
    186114     198820     Johnson     2
    186114     198910     Johnson     3
    186114     198920     Johnson     4
    186114     199010     Johnson     5
    186114     199020     Johnson     6
    186114     199110     Johnson     7
    186114     199120     Johnson     8 Edited by: 893973 on Sep 15, 2012 6:52 PM

  • How can we generate auto Sequence Number in DFF attribute

    Dear
    We are on r12,rignt now we have an issue to generate sequence number in site Level(DFF) on Supplier window,actully we want
    to generate sequence number on site leve while inserting new record on site level,so how could i achvie this or any way which can help us.
    --thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    You can consider writing a before-insert trigger.
    The trigger generates the next value of the sequence and makes :new.attributen = the sequence value.
    Hope this helps,
    Sandeep Gandhi

Maybe you are looking for