How to maintain a sequence of number for each execution of the view

Hi all

I would like to implement a vision that returns the sequence number (say, at 1 and increment a (num = num + 1)) for each performance.

for example, first, it should be 1 and then for the excution second it takes 2...

What is the best way to implement this scenario?

Please advice me...

Thank you

You cannot do it directly:

SQL> create sequence s
  2  /

Sequence created.

SQL> create view s_view
  2    as
  3      select  s.nextval s_value
  4        from  dual
  5  /
    select  s.nextval s_value
              *
ERROR at line 3:
ORA-02287: sequence number not allowed here

You could:

SQL> create or replace
  2    function s_func
  3      return number
  4      is
  5          v_retval number;
  6      begin
  7          select  s.nextval
  8            into  v_retval
  9            from  dual;
 10          return v_retval;
 11  end;
 12  /

Function created.

SQL> create view s_view
  2    as
  3      select  s_func s_value
  4        from  dual
  5  /

View created.

SQL>  

However, sequence will be calculated that whenever view column is referenced:

SQL> select  ename,
  2          s_value
  3    from  emp,
  4          s_view
  5  /

ENAME         S_VALUE
---------- ----------
MILLER              1
CLARK               2
KING                3
ADAMS               4
SMITH               5
JONES               6
FORD                7
SCOTT               8
JAMES               9
MARTIN             10
WARD               11

ENAME         S_VALUE
---------- ----------
ALLEN              12
BLAKE              13
TURNER             14

14 rows selected.

SQL>  select  ename,
  2           s_value,
  3           s_value
  4    from  emp,
  5          s_view
  6  /

ENAME         S_VALUE    S_VALUE
---------- ---------- ----------
MILLER             15         16
CLARK              17         18
KING               19         20
ADAMS              21         22
SMITH              23         24
JONES              25         26
FORD               27         28
SCOTT              29         30
JAMES              31         32
MARTIN             33         34
WARD               35         36

ENAME         S_VALUE    S_VALUE
---------- ---------- ----------
ALLEN              37         38
BLAKE              39         40
TURNER             41         42

14 rows selected.

SQL> 

You could create the deterministic function, but it does not guarantee still sequence value will be calculated once per request.

SY.

Tags: Database

Similar Questions

  • Adding column which gives the serial number for each line in the Bulletin Board

    I use the update version 2 Jdev 11 g.
    I'm the filling of all employees from the emp table ADF table.
    My requirement is to add a column more as the first column and header line which displays the serial number for each serial number of row.the is not available in the table emp in database .i want to generate it dynamically when the data are filled in to ADF table.i don't want not to use the method to get the SQL query rownum. I want to get custom code (in the Managed Bean) or set all of the properties in the subject entity or any other object.

    Published by: sj0609 on September 8, 2009 09:43

    Hello

    Give an id to the table (say 'currRow') varStatus property. Add a column to the table (for example with a text output), then set it to the value of the output text #{currRow.index}.

    Arun-

  • How can I get my serial number for my version of the education of the CS6?

    I am waiting for Adobe to send the serial number of my CS6 software newly purchased. My 30 day trial ran out. I need the software for the class. What can I do?

    Conatct S & T support by web chat or phone.

    Mylenium

  • How can I find my serial number for my products.

    How can I find my serial number for my products.  My account now lists some of my products and gives me the license agreement but no serial number.

    To locate the serial number:
    ----------------------------

    http://helpx.Adobe.com/x-productkb/global/find-serial-number.html

  • How can I find my serial number for my programs began?

    How can I find my serial number for my programs began?

    Hi aida_pc,

    Please choose the best option to retrieve the serial number. from there.

    http://helpx.Adobe.com/x-productkb/global/find-serial-number.html

    Hope this helps you.

    Kind regards

    Baudier

  • How can I get the serial number. for an edition of the education of cs6

    How can I get the serial number. for an edition of the education of cs6.  I try to save but not obvious how?

    Have you tried http://www.adobe.com/go/eduverify?

  • How to make a new serial number for my Acrobat 7?

    My computer crashed and when I try to install the professional Adobe Acrobat y, I had on the replacement, he tells me that the number is not valid. I was told that agents Bay Adobe I need to findout through this forum. Can anyone tell lme how to get a new serial number

    I have messaged the correct serial number in person, please see as there is no problem of activation.

    Concerning

    Stéphane

  • How to reset the value of line number for each header

    Hi all

    I need to reset the line number for each header values.

    create table header_table (header_value varchar2 (100));

    create table line_table (header_value varchar2 (100), number line_number);

    insert into header_table values ('ALAOF');

    insert into header_table values ('ALAOO');

    insert into line_table values('ALAOF',1);

    insert into line_table values('ALAOF',2);

    insert into line_table values('ALAOF',3);

    insert into line_table values('ALAOF',4);

    insert into line_table values('ALAOF',5);

    insert into line_table values('ALAOO,6);

    insert into line_table values('ALAOFO,7);

    insert into line_table values('ALAOO',8);

    insert into line_table values('ALAOO',9);

    insert into line_table values('ALAOO',10);

    insert into line_table values('ALAOO',11);

    insert into line_table values('ALAOO',12);

    Commit;

    TABLE HEADER_:

    header value

    ALAOF

    TRECYBEL

    LINE TABLE:

    header value line_number

    ALAOF 1

    ALAOF 2

    ALAOF 3

    ALAOF 4

    ALAOF 5

    TRECYBEL 6

    TRECYBEL 7

    TRECYBEL 8

    TRECYBEL 9

    TRECYBEL 10

    TRECYBEL 11

    TRECYBEL 12

    But looks like I got out of line below table

    LINE TABLE:

    header value line_number

    ALAOF 1

    ALAOF 2

    ALAOF 3

    ALAOF 4

    ALAOF 5

    TRECYBEL 1 <-reset the beginning of line number with 1 with different header value

    TRECYBEL 2

    TRECYBEL 3

    TRECYBEL 4

    TRECYBEL 5

    TRECYBEL 6

    TRECYBEL 7

    Please help me on this.

    Thanks in advance.

    Hello

    It makes no sense to do it in PL/SQL when you can do it with SQL.

    SQL is generally more efficient than PLSQL.

    And can you explain why you don't want to use analytical functions?

    This will update your table using a MERGE statement and an analytic function:

    MERGE INTO line_table lt
    USING
    (
       SELECT ROWID rid, header_value, row_number() OVER(PARTITION BY header_value ORDER BY ROWNUM) rn
         FROM line_table
    ) src
    ON (src.rid=lt.ROWID)
    WHEN MATCHED THEN
       UPDATE SET lt.line_number = src.rn;
    

    The result is less to:

    HEADER_VAL LINE_NUMBER

    ---------- -----------

    ALAOF 1

    ALAOF 2

    ALAOF 3

    ALAOF 4

    ALAOF 5

    TRECYBEL 1

    TRECYBEL 2

    TRECYBEL 3

    TRECYBEL 4

    TRECYBEL 5

    TRECYBEL 6

    TRECYBEL 7

    Kind regards.

    Al

  • How can I connect my Cruz Tablet for my connection to the internet the computer?

    Original title: How can I connect to my cruz Tablet

    How can I connect my Tablet cruz for my connection to the internet the computer

    Hello

    Thanks for posting your question in the Microsoft Community.

    I imagine the inconvenience that you are experiencing. I will certainly help the question of fixing.

    To help you suggest several steps to solve the problem, I would appreciate if you could answer the following questions:

    1. What is the model of the Cruz tablet number?

    2. How do you access Internet for your computer? It is through a wired connection or wireless?

    Follow the steps below:

    a. connect a network cable to the tablet computer if the Tablet has a network card. High-speed modems have an output connection to which you connect the network cable and then connect it to a computer or router.

    b. display wireless networks in network settings options. Select a wireless network, and then click on connect. In the areas of Wi - Fi hotspot, you may need to open a Web page to accept the terms of the license before plugging in.

    c. sign to a computer network or a network mobile broadband. Some tablet computers have connections to data network integrated such as the type that personal digital assistants (PDAS) and the use of cell phones. You need to register for an account with the provider of service associated with the integrated network. Alternatively, you can sign up for broadband wireless services and to access broadband that plugs into a USB port with an adapter.

    For more information, please communicate with the link below:

     

    http://www.velocitymicro.com/SupportPage.php

     

     

     

    Your response is very important for us to ensure a proper resolution. Please get back to us to help you accordingly.

  • How can I create sequential shooting (1 for each 'row') numbers in a script in multiple column?

    How can I create sequential shooting (1 for each 'row') numbers in a script in multiple column?

    Sorry, but for now there no such function to put sequential numbers in the column number drawn.

  • How can I make a cell formula will apply for the entire column? For example D2 appears B2 - C2. How can I copy this formula for each cell in the column?

    How can I make a cell formula will apply for the entire column? For example D2 appears B2 - C2. How can I copy this formula for each cell in the column?

    If you want the formula is the same (B2 - C2) in the cell of each column you must change it as ($B$ - 2$ C$ 2). Then copy it, select the whole column and paste.

  • number for each record that is extracted (query)

    Hello
    I want to what a number for each record that is retrieved from the recording which was released by this query

    For example
    For the first line/recored
    Number generated, ksnumber, date
    1, gg111 11/05/05
    2, oo235 06/12/05

    the query returned 2 records 1 and 2 are the number generated by this code.
    In addition if it is built in function, where in the code can I put it?


    < cfquery = name "gelov datasource ="kl90">"
    SELECT
    -------------------------------------------

    Of
    --------------------------------
    WHERE
    -----------------------------------------
    -----------------------------------------------------

    ORDER BY
    < cfswitch expression = "#Form.orderBy #" >
    < cfks value = "KSNUMBER" >
    KS. KS_NBR
    < / cfks >
    < cfks value = "DATECREATED" >
    KS. KREATDAT
    < / cfks >
    < / cfswitch >
    < / cfquery >

    <! - report html - >
    < cfswitch expression = "#Form.outputFormat #" >
    < cfks value = "HTML" >

    <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional / / IN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
    "< html xmlns =" http://www.w3.org/1999/xhtml "> "
    < head >
    < meta http-equiv = "Content-Type" content = text/html"; charset = iso-8859-1 "/ >"
    Report Kss Ctwye < title > < / title >
    < / head >
    < style type = "text/css" >
    table {}
    do-family: Arial, Helvetica, without serif.
    do-size: 10px;
    }
    TD {}
    do-family: Arial, Helvetica, without serif.
    do-size: 10px;
    }
    Th {}
    do-family: Arial, Helvetica, without serif.
    do-size: 10px;
    }
    H2 {}
    do-family: Arial, Helvetica, without serif.
    do-size: 12px;
    }
    H3 {}
    do-family: Arial, Helvetica, without serif.
    font-size: 13px;
    }
    < / style >

    < body >
    < cfoutput >
    < table border = "0" cellpadding = "3" cellspacing = "0" >
    < b >

    < td align = "center" >
    Kss Ctwye report < h3 > < / h3 > < br > < br > < table >
    < /tr >
    < b >
    < td align = "center" >
    < / h2 > report returned #getCtwyeKss.RecordCount # entries < / h2 > < table >
    < /tr >
    < b >
    < td >
    < table border = "1" cellpadding = "2" cellspacing = "0" >
    < b >

    < td width = "160" > Ks number < table >
    Date of creation of the < td > < table >
    <!-< class = 'dataField' td > address < table >
    < class td 'dataField' = > Type < table >
    < class td 'dataField' = >-> Description < table >
    < /tr >

    < cfloop query = "getCtwyeKss" >


    < tr bgcolor = "< cfif currentrow mod 2 > F8F8FF < cfelse > WHITE < / cfif >" >
    < td > #KS_NBR # < table >
    < td > #dateformat(KREATDAT,"mm/dd/yyyy") # < table >


    < /tr >
    < / cfloop >

    < /table >
    < table >
    < /tr >
    < /table >

    < / BODY >
    < / HTML >
    < / cfoutput >
    < / cfks >

    < cfks value = "CSV" >


    < NAME CFHEADER = "Content-Disposition" VALUE = "attachment; filename = ctwye.csv">
    < cfcontent type = "application/msexcel" > "Ks number", "Date of creation".
    < cfoutput query = "getCtwyeKss" > #ltrim (KS_NBR) #, "#dateformat(KREATDAT,"mm/dd/yyyy")" # "< tr #IIF (getCtwyeKss.CurrentRow MOD 2, OF (»), DE('backgroundColor="##999"')) # >"



    <!-< tr bgcolor = "< cfif currentrow mod 2 > # 808080 < cfelse > ##ffffff < / cfif >" >-->
    < / cfoutput >


    < / cfks >
    < / cfswitch >


    is not a Coldfusion tag. Use instead.

    The following code prints line numbers


    Select ksnumber, date
    from yourTable


    #currentrow #, #ksnumber #, #date #.

  • How can I add a different title for each slide in a slideshow of LR3?

    This question has been asked, but for some reason I can't access it.  Thank you!

    John,

    You add a separate title and/or caption for each picture in the metadata Panel, and then refer to these metadata fields in the slideshow with a text field.

    Gossweiler beat

    Switzerland

  • Loading the default limits for each execution

    Hello

    My situation is like this:

    I spend my sequence using the sequential model. Usually, the sequence is executed, 'in the loop', which means that when once the sequential model is launched, we can test unit after unit until we want to put an end for some reason any. The sequence is load dynamically by the sequential model and download after executing the step to discharge option.

    In the sequence, we use limits. Default TS limits similar to below.

    All our limitations change during execution depending on what unit we test and on what stage is the unit.

    Problem:

    I thought that if the sequence is loaded dynamically, it is unloaded when executing the next time that the next unit will be tested the default values of the container limits will be charged (in response to being dynamically loaded and unloaded at the step which called the main sequence is executed). Unfortunately, it seems that when we realize continous test the test limits have not returned to the default value, as expected, but they are a superposition of the limits assigned by previous executions. Of course

    Issues related to the:

    1 are my expectations about the behavior of TS are correct?

    2. how to impose default deadline to be 'reset', the default value for each run of the sequence, not only the first execution of sequential model?

    MimiKLM wrote: I am worry the speed of loading, you talked about associated to your solution, but potential problems with memory. Let say, I called the main sequence of 1000 times without breaking execution. So instead of having one copy of the sequence called with wiped/reset all variables and properties I have 1000 copies in the memory. I would call it a waste to have 1000 copies only because I need to have the properties and variables deleted.

    The copy exists only during the execution of the sequence. Once the execution of the sequence is complete, the copy will be destroyed/released. At least as long your code modules do not hold their own reference to it somewhere (which generally do not do).

    If you call from the main sequence 1000 times in a loop, you must still do not have a runtime copy into memory at once. The difference is a new copy is created (and destroyed once that the sequence is made running) each time, rather than create a copy only once and reuse. There is a performance hit in this call of your sequence which is somewhat proportional to the size of your sequence, but unless your sequence is really huge, or test you execution is extremely fast, you probably won't see the difference.

    Hope this helps to clear things up,

    -Doug

  • Select a record for each Member of the Group

    Hello
    will have a table where in I'll take data for so many members of the group. I need to retrieve data for a particular group whose number of rows of data may be more in number (but I don't want only one row of data for each Member of the Group)

    Here is the query to retrieve all rows of data
    select RI.RESOURCE_NAME,TR.MSISDN,TR.ADDRESS1_GOOGLE, TR.MSG_DATE_INFO, FROM TRACKING_REPORT TR, RESOURCE_INFO RI 
    WHERE TR.MSISDN IN (SELECT MSISDN FROM RESOURCE_INFO WHERE GROUP_ID ='1' AND COM_ID=2 ) AND RI.MSISDN=TR.MSISDN 
     order by MSG_DATE_INFO
    This query result is...
    >
    DDD 12345 13 March 10 19:43:03
    EEE 54321 Tamilnadu, India 13 March 10 19:39:48
    DDD 12345 13 March 10 19:32:58
    EEE 54321 Tamilnadu, India 13 March 10 19:30:07
    DDD 12345 13 March 10 19:23:08
    EEE 54321 Tamilnadu, India 13 March 10 19:20:14
    FFF 98765 March 13 10 19:19:22
    DDD 12345 13 March 10 19:13:01
    EEE 54321 Tamilnadu, India 13 March 10 19:09:50
    DDD 12345 13 March 10 19:02:56
    EEE 54321 tn, ind March 13, 10 18:59:49
    DDD 12345 13 March 10 18:53:08
    EEE 54321 tn, ind March 13, 10 18:49:50
    DDD 12345 13 March 10 18:42:56
    EEE 54321 tn, ind March 13, 10 18:39:50
    DDD 12345 13 March 10 18:33
    EEE 54321 tn, ind March 13, 10 18:29:50
    DDD 12345 13 March 10 18:22:54
    EEE 54321 tn, ind March 13, 10 18:19:50
    DDD 12345 13 March 10 18:12:56
    EEE 54321 tn, ind March 13, 10 18:09:50
    DDD 12345 13 March 10 18:02:54
    EEE 54321 tn, ind March 13, 10 18:00:02
    FFF 98765 Tamilnadu, India March 13, 10 17:59:26
    FFF 98765 Tamilnadu, India March 13, 10 17:54:26
    DDD 12345 13 March 10 17:52:56
    EEE 54321 tn, ind March 13, 10 17:49:50
    FFF 98765 Tamilnadu, India March 13, 10 17:49:25
    FFF 98765 Tamilnadu, India March 13, 10 17:44:26
    DDD 12345 13 March 10 17:42:56

    >

    This output, I only want a new album for each member(ddd,eee,fff). That is to say
    >
    DDD 12345 13 March 10 19:43:03
    EEE 54321 Tamilnadu, India 13 March 10 19:39:48
    FFF 98765 March 13 10 19:19:22
    >

    How to change the query to do this...?

    Ok. I looked more carefully at your sample and it looks like you are looking for:

    SELECT  RI.RESOURCE_NAME,
            TR.MSISDN,
            MAX(TR.ADDRESS1_GOOGLE) KEEP(DENSE_RANK LAST ORDER BY TR.MSG_DATE_INFO),
            MAX(TR.MSG_DATE_INFO)
      FROM  TRACKING_REPORT TR,
            RESOURCE_INFO RI
      WHERE TR.MSISDN IN (
                          SELECT  MSISDN
                            FROM  RESOURCE_INFO
                            WHERE GROUP_ID ='1'
                              AND COM_ID=2
                         )
        AND RI.MSISDN = TR.MSISDN
      GROUP BY  RI.RESOURCE_NAME,
                TR.MSISDN
    / 
    

    SY.

Maybe you are looking for