TCP Sequence/Acknowledgement numbers

Hello everyone,
Please excuse me if this question is somewhat rudimentary, but I was as much looking for reassurance as anything else.
As I understand TCP sequence numbers and Acknowledgments, in a nutshell it's case that:
A Sequence number is sent from the host and is total number of bytes sent UP to this point, during the conversation, not including the current payload
The acknowledgement number would be the total number of bytes recevied by the destination, FROM the sender, plus one (i.e. the one being the next byte it expects to get).
Assuming this is right, I am somewhat confused by the following explanation, taken from this article (page 2): 
https://www.novell.com/connectionmagazine/2001/05/sequence51.pdf
Explanation goes:
Host 1 ———> 
Sequence number 1 with 9 bytes of data 
Acknowledgment number field = 100
<——— Host 2
Sequence number 100 with no data (ACK)
Acknowledgment number field = 10 (in 1 + 9 bytes of data)
Host 1 ———>
Sequence number 10 with 5 bytes of data 
Acknowledgment number field = 100
<——— Host 2
Sequence number 100 with no data (ACK)
Acknowledgment number field = 15 (in 10 + 5 bytes of data)
<——— Host 2
Sequence number 100 with 20 bytes of data 
Acknowledgment number field = 15
Host 1: ———->
Sequence number 15 with no data (ACK) 
Acknowledgment number field = 120 (in 100 + 20 bytes of
data)
If you would be so kind, I'm sort of looking for some confirmation that, in a nutshell, my appraisal as right, and also that the above explanation between Hosts 1 and 2 is a little confusing.
As a side note, I believe only the SYN and FIN flags actually count as payload data, and the article above begins at Byte 1 but makes no mention of SYN.
Thank you for reading.

Hi,
I believe the example is correct. Let's take it apart:
Host 1 ———> 
Sequence number 1 with 9 bytes of data 
Acknowledgment number field = 100
Host1 sends 9 bytes, numbering them from 1 (the Seq). The last byte is numbered as 9, and the subsequent byte will be numbered as 10 so this is what Host2 should acknowledge in its own segment. In addition, Host1 asks Host2 to continue sending data starting with the sequence number 100 (the Ack).
<——— Host 2
Sequence number 100 with no data (ACK)
Acknowledgment number field = 10 (in 1 + 9 bytes of data)
As requested by Host1, Host2 sends a segment with Seq=100. Because Host2 received the 9 bytes from Host1, it acknowledges them and tells Host1 to continue sending bytes starting with Seq=10.
Host 1 ———>
Sequence number 10 with 5 bytes of data 
Acknowledgment number field = 100
Host1 continues sending data starting from Seq=10, and with 5 sent bytes, these are numbered 10-14. The next byte would be 15 which is the Ack number expected from Host2. Because Host2 did not send any data itself, Host1 just tells Host2 again to continue sending data, if any, starting with sequence number 100 (the Ack).
<——— Host 2
Sequence number 100 with no data (ACK)
Acknowledgment number field = 15 (in 10 + 5 bytes of data)
Host2 has received additional 5 bytes from Host1 numbered as 10-14, so it sends back a segment with Ack=15 (all up to 14 is received, continue with 15). As there are no data to be sent by Host2 at this point, the Seq=100 and the body is empty.
<——— Host 2
Sequence number 100 with 20 bytes of data 
Acknowledgment number field = 15
Host2 suddenly has a data to send, and the bytes start with the sequence number of 100, so this is the Seq. Because no further bytes arrived from Host1 yet, we simply tell it to continue with byte 15 whenever Host1 has any bytes to send.
Host 1: ———->
Sequence number 15 with no data (ACK) 
Acknowledgment number field = 120 (in 100 + 20 bytes of data)
Host1 has no data to send itself but it needs to acknowledge the received data from Host2. There were 20 bytes in the segment received from Host2, starting from 100 and ending with 119. The upcoming expected byte from Host2 is thus 120, hence the Ack field value. The Seq field value is 15, the upcoming byte number.
As a side note, I believe only the SYN and FIN flags actually count as payload data
This is true.
and the article above begins at Byte 1 but makes no mention of SYN.
In fact, the article above seems to omit the TCP session establishment phase, and simply starts showing the Seq and Ack values in the midst of an already established session.
Please feel welcome to ask further!
Best regards,
Peter

Similar Messages

  • How to update the acknowledgement numbers of Qtly statements in TDS cert?

    Dear All,
    In the TDS certificate printing for India, there is a field to fill teh acknowledgement numbers of all the quarterly statements of TDS. How do we update this field. What is the transaction or the setting to do this.
    Kindly provide your valuable inputs
    regards
    AK

    you ahve to apply oss note 1046758.
    even i am also working on the same.
    reward points if useful
    Edited by: ramyav on Apr 1, 2008 10:35 PM

  • TCP Sequence number in Java domain

    Hi,
    Trying to get a platform unique number I thought about a combination between IP address and the local machine TCP sequence number.
    Is there a way in Java to get the TCP sequence number?
    Thanks,
    -Michael

    I don't think you can get down to that level. Java 1.6 might allow this when it is released.
    There have been several posts today about determining "machine uniqueness". Usual solutions rely on platform-specific code to get some low-level network information (e.g. MAC address). The problem with this is
    1) It currently relies on native calls (1.6 should have an API for MAC address though).
    2) MAC addresses (local IP addresses, machine names, etc) can easily be changed/spoofed.
    If you're using 1.5 and your code runs on the client-side, there is a pure-java fix you can do. You can generate a java.util.UUID for each machine when your software first runs, then store this value using the Preferences API. This number will persist until the OS is wiped.

  • Acknowledgement numbers for quarterly returns filed

    Dear All,
    I am trying to pritnt TDS Certiicate, but in the certificate my Acknowledgement numbers are not appearing, I have maintained in table also.
    Can you please provide me is there any other settings i need to do for getting Acknowledgement numbers.
    I am using 4.6C Version
    Regards
    Edited by: Sudheer Reddy on Feb 4, 2009 11:49 AM

    Dear Sudhher,
    There is no facility to enter that same return number in SAP. So create noted entries or assign the same number to set off document number assignment filed.
    Best Rgds
    Suma

  • Strange display of a long sequence of numbers - Should I press OK ?

    From type to time my iphone displays a long sequence of numbers and waits for me to press a green "OK" button. For example last sequence starts with 1259752976 1 199.664277......
    Anybody knows what's going on ?

    Yolanda,
    Yolanda Arroyo wrote:
    Hi folks,
    I have problems with my Tuxedo cofiguration using domains.
    I have Tuxedo8 installed in Linux 7.1. It connects to an Oracle 8.1.7 database,
    and has 2 domains cofigured to connect to a remote domain. (this domain is in
    fact WebLogic Server 6.1 running in the same machine)
    If I run this configuration, the servers in LDOM2 (for example, server1) are not
    able to connect to the database (this group don't include a TMS because is
    associated with the domain, and I cannot put an OPENINFO information in that
    group, for the same reason)
    BUT!!!! the most amazing thing is that, if I make no changes in the bdmconfig
    file, and in the UBBCONFIG I change the group WTC2 for a group that contains a
    TMS, in this way:
    I think that you are confusing the purpose of the 2 config files, ubbconfig and
    dmconfig.
    You should configure you application servers in the ubbconfig file. They
    should be in server groups configured with the correct TMS servers, OPENINFO, etc.
    One you have done this, you have a single domain.
    To extend this to talk to external domains, now you need to configure the gateways.
    Add a new server group to your ubbconfig and configure the domain gateway
    processes (GWADM, DMADM, GWTDOMAIN) in it. This group does not need a TMS (TMS
    services are provided by the domain gateway) or any OPENINFO.
    Now, write a dmconfig file. This does not reference any servers it does
    reference services that you want to import from other domains, or export to them.
    I hope this explains how you can successfully get your configuration working...
    Regards,
    Peter.

  • Cryptic sequence of numbers as sender name for invitations

    When I want to send an calendar invitation to my business address, my sender name is a cryptic sequence of numbers instead of "first name last name". These are the steps:
    1. Receiving Email form my iPad with the invitation
    2. Download the attached ics to my desktop of the windows PC
    3. Drag&Drop the ics to the Lotus Notes Calendar
    4. The invitation is visible, the sender name is i.e. 2fjfu3oodsjdf90499fj993efj0ßßejfefjß39eß939hgsdlfnasdäfa9e9
    I know that this invitation is from my private account. But what about friends I wanted to invite? Or should I invite only friends with apple equipment?!?! ;-)

    Well,
    Nokia MfE doesn't reply to my mails. I guess that only poeple using MfE v 2.09.158 who are not registered to the MfE Service (I guess you have to pay a monthly fee as it is with the Blackberry service) have the sender name problem. Of course you can use MfE with other mail providers than Nokia MfE. But in this case "Mail for Exchange" will appear as sender name.
    I now switched over to MfE's competitor "RS" and don't have this annoying problem anymore. The alternative to RS would be using the old MfE version where I didn't have that sender name prob. But as my battery was empty after 15 hrs using the old MfE version (with RS my battery lasts 3 days !!!) there is no real alternative to RS!
    This sender name problem seems to be part of Nokia's business strategy. As they want to compete with Blackberry they want you to register (and pay the MfE mail service monthly). Probably that's the reason why you get MfE for free (RS costs 50 US$).
     Any comments on my theory?!
    BR, Johnny

  • Updation of TDS return Acknowledgement numbers Section code wise

    Hi
    I want to update the Acknowledgement numbers for TDS return filed.
    We have many business place and section codes. But in Table J_1IEWT_ACKN_N there is no field for business place and section code.
    Help me to do this on priority.
    Regards
    Ajay

    Hi ,
    Have a Look , TDS Certificate
    Regards ,
    Swapnil vaidya

  • How to remove "TCP Sequence Number Approximation Based Denial of Service" vulnrability ???

    Hi Friends,
    In our weekly security scan , following vulnrability has been detected "TCP Sequence Number Approximation Based Denial of Service" . could you please any one let us know , hot to remove or mitigate this vulnrability ???
    Thanks!

    Hello,
    Please provide more details, specifically the 'port(s)' involved, the target service if known, the scanner in question, the version of ESXi scanned.
    I.e. all ports, general, Nessus, ESXi 5.x
    Best regards,
    Edward L. Haletky
    VMware Communities User Moderator, VMware vExpert 2009, 2010, 2011,2012,2013,2014
    Author of the books 'VMWare ESX and ESXi in the Enterprise: Planning Deployment Virtualization Servers', Copyright 2011 Pearson Education. 'VMware vSphere and Virtual Infrastructure Security: Securing the Virtual Environment', Copyright 2009 Pearson Education.
    Virtualization and Cloud Security Analyst: The Virtualization Practice, LLC -- vSphere Upgrade Saga -- Virtualization Security Round Table Podcast

  • CTC TCP/UDP Ports numbers

    Does anyone know the TCP/UDP Port numbers that have to be opened up when using NAT, this is what I have:
    CTC PC >>>>>>>>>>> ROUTER >>>>>>>>>>>ONS15454
    The CTC PC and the ONS are on different IP Networks so I'm the router to translate from one to the other with NAT, configured the ONS15454 to use Socks.
    I used to have a document that explained this but I've lost it.
    THanks
    Chris

    Hi Chris.
    I see you already have provisioned the node for SOCKS Proxy.  If you want to be able to still have IP connectivity (for ping or telnet) to the ENE's, then enable the SOCKS Proxy Only option.  The SOCKS Proxy needs to be provisioned on the LAN connected 15454 at the very least.  You can also go to the CTC drop down menu:  Edit -> Preferences -> Firewall and change the port from being variable to static default.  That will further restrict the ports that are used by CTC.  This should resolve any intermittent connectivity issues in CTC if it is being caused by a firewall.
    www.cisco.com/en/US/docs/optical/15000r9_1/15454/sonet/reference/guide/454a91_nwconnectivity.html#wp42216
    "If  you launch CTC against a node through a Network Address Translation  (NAT) or Port Address Translation (PAT) router and that node does not  have proxy enabled, your CTC session starts and initially appears to be  fine. However, CTC never receives alarm updates and disconnects and  reconnects every two minutes. If the proxy is accidentally disabled, it  is still possible to enable the proxy during a reconnect cycle and  recover your ability to manage the node, even through a NAT/PAT  firewall."
    Lastly, to answer your question directly below is a link to the list:
    www.cisco.com/en/US/docs/optical/15000r9_1/15454/sonet/reference/guide/454a91_nwconnectivity.html#wp59962
    Table 14-6 Ports Used by the TCC2/TCC2P
    Thanks,
    Will

  • 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; }
    }

  • Find gaps in sequence of numbers

    Hi,
    I'm trying to scan through multiple records containing millions of numbers. What I need to do is to print out the numbers that are sequential as such:
    If the record contains a sequence like this:
    46859995600
    46859995699
    And there is no breakage in that sequence, then print:
    46859995600 100
    If that sequence is broken somewhere, then print series of 10 that are sequential, f.e:
    46859995600 10
    46859995620 10
    46859995630 10
    I already have a bash script for this, but it's way too slow. If anyone can help me out I'd be very grateful, perhaps a "awk" solution.
    Thanks!

    Indeed.  Also, note that the code above makes several assumptions: 1) monotonicity ... but "sort" can take care of that; 2) there is no zero.  This would be easy to fix, but in the first draft I didn't bother with it: 000-009 will not currently be counted; 3) the application is not mission critical; 4) there are no blank line; 5) each line contains *only* the number.
    On #3, my code may be faster, but it hasn't been checked for accuracy.  Be sure to test for accuracy before trusting its output.  In fact, I just tested it ... it failed.
    I tested it after I recoded it in C.  The speed went from 2min 3sec to 0.39sec ... that's nice.  But the results file was *much* smaller.
    The results from the bash version includes several duplicates, and some erroneous inclusions.  Given that so far the C version seems more accurate (but still needs testing) and *much* faster, I'd go with patching this up further:
    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    unsigned long lt = 0, lh = 0;
    unsigned long n, prev = 0, tens[10];
    int nten=0;
    void check_tens() {
    int i;
    if (lh) printf("%lu 100\n",lh);
    else for (i = 0; i < 10 && tens[i]; i++)
    printf("%lu 10\n",tens[i]);
    memset(tens,0,10*sizeof(unsigned long));
    nten = 0;
    int main() {
    int i;
    memset(tens,0,10*sizeof(unsigned long));
    while (fscanf(stdin,"%lu\n",&n) == 1) {
    if ((n % 10) == 0) lt = n;
    else if ((n % 10) == 9) {
    if (!lt || n - 9 == lt) tens[nten++] = lt;
    lt = 0;
    if ((n % 100) == 0) lh = n;
    else if ((n % 100) == 99) check_tens();
    if (n - prev != 1) {
    lt = lh = 0;
    for (i = prev; i < n; i++)
    if ((i % 100) == 99) { check_tens(); break; }
    if ((n % 10) == 0) lt = n;
    if ((n % 100) == 0) lh = n;
    prev=n;
    lh = 0;
    check_tens();
    return 0;
    EDIT: I can actually confirm the C version is not yet accurate.  ARGH!
    Last edited by Trilby (2014-05-02 00:11:09)

  • Trouble with SEQUENCE, loosing numbers

    Hi all, I use a sequence to generate the number of an invoice like this:
    Insert into table
    values(owner.sequence_name.nextval);
    But, if an error occurs this number get lost because of the way the sequence works, how can I avoid this??, there is another way to do it??? It doesnt matter if that solution doesn't use the sequence, but my design cannot accept numbers like 1,3,4,5,7, it has to be 1,2,3,4,5,6,7....
    Leo
    null

    Unfortunately, this is another one of those concepts that sounds simple but isn't.
    Yours is not an Oracle (or any other DB) problem; it is a design problem.
    The reason that none of the suggested alternatives solve your problem is that there are undefined elements in your requirements.
    There are actually two aspects to your of problem: 1) generating unique sequential numbers and 2) using those numbers.
    I would suggest starting over and try to clearly define the problem and the requirements.
    For example your stated requirements appear to be something like:
    1. Invoice numbers must to be unique
    2. Invoice numbers must be numeric
    3. The first invoice number must be 27 (modify per your requirements)
    4. Each new invoice must be numbered one higher than the previous invoice.
    5. Invoice numbers must be sequential with no missing numbers.
    While the above list seems to be complete there are some very important questions that are not yet answered.
    1. When does an invoice become an invoice? That is, when is the invoice number assigned? Is the number assigned before or after the invoice record is committed to the database? If the number is assigned before committing (e.g. when the user begins processing an invoice) but the invoice is then abandoned and never committed there will be a gap in invoice numbers.
    2. Can invoice records ever be deleted? If a committed record is deleted there will be a gap in the numbers. Some systems handle deletions by either flagging the records as deleted without actually deleting them or moving the records to a deleted table so that all invoice numbers are always accounted for.
    Check printing applications used to print on pre-numbered check forms. The line printers that were used had sprockets to feed the checks and the first check could not be printed on since the sprockets were above the print head. The operator would enter the first check number into the system and the application created a check record marked VOID for that check number. This ensured that all pre-printed checks were accounted for and had not been misplaced or stolen.
    Oracle's sequence generator can generate sequence numbers in sequential order and ensure that there are no gaps in the generation process.
    Oracle cannot ensure that your application uses those numbers in a way that avoids gaps.
    Even a normal INSERT trigger that might be used to get the next sequence value cannot be certain that the record it is inserting will actually be committed unless the COMMIT operation is performed within the trigger.
    Sorry to 'rain on your parade' but withouth a better problem definition we can't give you a better solution.

  • TCP sequence number

    hi!
    I'm using a socket connection in my j2me application and i need to know the sequence number of every tcp packet that i receive, can i do that?
    I was searching and i didn't find anything...
    thanks!

    http://www.ietf.org/rfc/rfc1889.txt and
    http://today.java.net/pub/a/today/2006/08/22/experiments-in-streaming-java-me.html
    infos here

  • Comparing a sequence of numbers

    Morning Everyone,
    I have a little challenge on board and would like to have some ideas about how to proceed with it.
    As you all are aware of the Lotto game. u have to choose 6 numbers out of 40. There are exactly 3,838,380 combinations that can be played.
    these combinations can be generated and stored in a table.
    Now lets say i have 1000's people playing and i would like to find a way to know how many combinations are repeating and also what combinations have not been played.
    How can i do that?
    Kind Regards
    Kevin

    Billy Verreynne wrote :
    The universe does not keep a scoreboardWell, actually, you cannot prove that. Maybe it does...
    :D
    To the OP.
    I think you can generate the table containing all possible combination using the following query (assuming that you cannot chose the same number twice) : with b as (select level n from dual connect by level <=40)
    select count(*)
    from (
    select
    b1.n,
    b2.n,
    b3.n,
    b4.n,
    b5.n,
    b6.n
    from b b1, b b2, b b3, b b4, b b5, b b6
    where
    b6.n>b5.n
    and b5.n>b4.n
    and b4.n>b3.n
    and b3.n>b2.n
    and b2.n>b1.n
    /I just ran the count(*) on the query and it brings me 3838380 rows, as expected.
    the query gives each row with the 6 different values in ascending order (1st column being < than 2nd, being < than 3rd, and so on).
    If you want to compare with played combination, you should make sure you store those combination the same ways (col1 < col2 < col3 ...) using a constraint on the table.
    SQL> create table possible_combinations (
      2  c1 integer not null,
      3  c2 integer not null,
      4  c3 integer not null,
      5  c4 integer not null,
      6  c5 integer not null,
      7  c6 integer not null,
      8  primary key (c1,c2,c3,c4,c5,c6)
      9  );
    Table created.
    SQL> alter table possible_combinations add constraint asc_ordered check (c6>c5 and c5>c4 and c4>c3 and c3>c2 and c2>c1);
    Table altered.
    SQL> insert into possible_combinations
      2  with b as (select level n from dual connect by level <=40)
      3  select
      4  b1.n,
      5  b2.n,
      6  b3.n,
      7  b4.n,
      8  b5.n,
      9  b6.n
    10  from b b1, b b2, b b3, b b4, b b5, b b6
    11  where
    12  b6.n>b5.n
    13  and b5.n>b4.n
    14  and b4.n>b3.n
    15  and b3.n>b2.n
    16* and b2.n>b1.n;you can then create another table that store the played combinations :
    SQL> create table played_combinations(
      2  userid integer not null,
      3  dateplay date not null,
      4  c1 integer not null,
      5  c2 integer not null,
      6  c3 integer not null,
      7  c4 integer not null,
      8  c5 integer not null,
      9  c6 integer not null);
    Table created.
    SQL> alter table played_combinations add constraint playordered check (c6>c5 and c5>c4 and c4>c3 and c3>c2 and c2>c1);
    Table altered.You can easily get :
    - the number of time a combination was played :select c1, c2, c3, c4, c5, c6,
    count(*) Nbr_of_time_played,
    trunc(100*count(*)/(select count(*) from played_combinations),3) pct_of_played
    from played_combinations
    group by c1, c2, c3, c4, c5, c6
    order by count(*) desc;-the list of combinations that were never played :select t.c1, t.c2, t.c3, t.c4, t.c5, t.c6
    from possible_combinations t
    where not exists (select null
    from played_combinations p
    where t.c1=p.c1
    and t.c2=p.c2
    and t.c3=p.c3
    and t.c4=p.c4
    and t.c5=p.c5
    and t.c6=p.c6
    );

  • Inserting a Sequence of Numbers

    Hi all
    I have a number field restricted to 3 digits, and when someone navigates to the block to insert a record I want the number field to display 001 to state this is the first record, then if a second record is inserted put in 002 etc. Currently you can go and put any old 3 digit number in but I want to restrict it to a display field only, showing the number of records in this block in a sequence, for a particular parent record.
    I am trying to work out the following:
    How to build a counting generator (the most obvious bit)
    How to get the count generator to recognise what the existing number is (related to the parent record) and insert the next sequence of number say it is 001, then it now needs to put in 002.
    I currently have this piece of code (and result) as a start and am finding it difficult to decide how to build on it from that:
    SELECT ltrim (to_char (rownum, '009'))
    FROM dual
    LTRI
    001
    Any ideas on this would be appreciated.
    Thanks
    USER605593

    If you had a date column which held the date the row was added (or whatever it is that denotes the order) then you don't need to bother with an explicit sub sequence in the table.
    eg.
    with my_data as (select 1 record_id, 'hello' val, trunc(sysdate) -1 date_inserted from dual union all
                     select 1 record_id, 'there' val, trunc(sysdate) -1 + 2/24 date_inserted from dual union all
                     select 1 record_id, 'sailor' val, trunc(sysdate) -1 + 5/24 date_inserted from dual union all
                     select 1 record_id, 'boy' val, trunc(sysdate) -1 + 18/24 date_inserted from dual union all
                     select 2 record_id, 'hi' val, trunc(sysdate) -1 + 1/24 date_inserted from dual union all
                     select 2 record_id, 'ho' val, trunc(sysdate) -1 + 12/24 date_inserted from dual union all
                     select 2 record_id, 'off to work' val, trunc(sysdate) -1 + 13/24  date_inserted from dual union all
                     select 2 record_id, 'we go' val, trunc(sysdate) -1 + 23/24  date_inserted from dual union all
                     select 3 record_id, 'good' val, trunc(sysdate) -1 + 1.5/24 date_inserted from dual union all
                     select 3 record_id, 'bye' val, trunc(sysdate) -1 + 5/24 date_inserted from dual union all
                     select 4 record_id, 'geronimo' val, trunc(sysdate) -1 + 4/24 date_inserted from dual)
    -- end of data setup. Query below:
    select record_id, val, row_number() over (partition by record_id order by date_inserted) rn
    from   my_data
    RECORD_ID     VAL     RN
    1     hello     1
    1     there     2
    1     sailor     3
    1     boy     4
    2     hi     1
    2     ho     2
    2     off to work     3
    2     we go     4
    3     good     1
    3     bye     2
    4     geronimo     1This has the added advantage that if you need to insert a row at the end or in the middle, the ordering will automatically be taken care of. If you store the number, you then have to work out a way of updating the sub-sequence number manually. (Obviously, you'll have to format the rn into the 3 digit format for your display purposes, but you already know how to do that.)

Maybe you are looking for

  • Good software for mass mailing.

    We have been using mac for a while for design etc, but have relied on windows to send email marketing campaigns out. We have a huge list of 35,000+ emails to send newsletters/offers to. MAC address book cannot hadle that amount of contacts, so i am w

  • Photographic 360deg panorama

    I am thinking of using 360 degree photo panoramas of gardens on my website. There are many packages on the market. would any one one of you have experience with these programs and/or can recommend a package, which might be reasonably easy to use and

  • Smartview tab and Adhoc Analysis Issue

    Hi, I am unable to see the smartview(Hyperion) tab in Excel , how ever i can see the options to connect Datasources and i can see the all other smartview options in in excel window, but when i select one of the planning type(Datasource) and then i cl

  • Menu Extras - missing help files

    I have tried to use menu meters BUT I get a message saying "Menu Extra Could Not Load... for instructions on enabling third-party menu extras please see the documentation". However there is NOTHING to refer to on either the DVD, Apple help pages or t

  • Quick Question: Is CCMS installed on NW2004s support BW3.1 and R3 4.5?

    Dear Sapadmin! I just curious to know can CCMS configured on BW3.1 and R3 4.5 System? As for as i know, i think this shouldnt be any issue as we just need to ensure saposcol and sapccm4x is installed and running on monitored system. Basically, our re