How to identify when there is a break in continuity of an integer

Hi guys, 
Can you give me an idea on how to solve the following issue?
column01       column02       column03       column04      
1                    001                 002                  0                
2                    003                 004                  0
3                    009                 010                  1
4                    015                 018                  1
5                    019                 020                  0
so basically the fourth column (column04) is what I want to get if I am given the three columns. The flag 0 or 1 will be applied in the forth column if column02 is not a follow up number of the previous row's column03 value. 
example, column04 is o for the second row because column03 os the first row is 2 and column02 of the second row is 3...hence 3 is the next number to 2.
thanks in advance
ebro

Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI', 'ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We
need to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI', 'ISO Standard SQL. And you need to read and download the PDF for: 
https:www.simple-talk.com/books/sql-books/119-sql-code-smells/
>> Can you give me an idea on how to solve the following issue? <<
No, we have to only guess. Why did you fail to post DDL? The silly picture of a table you posted has no name, no keys, no constraints. Yet you expect other people to read your mind.  
Why are you using flags in SQL? That was assembly language.  SQL is based on logic and predicates; we like to detect the actual state of being in the schema. Your ASCII picture shows leading zeros on some of th4e columns, so they have to be strings; sure
would help if you told us if this guess is right. 
Here is my first attempt at doing what you shroud have done if you were polite: 
CREATE TABLE Foobars
(foobar_seq INTEGER NOT NULL PRIMARY KEY, -- did I guess right?? 
 col_2 CHAR(3) NOT NULL CHECK(col_2 LIKE '[0-9][0-9][0-9]), 
 col_3 CHAR(3) NOT NULL CHECK(col_3 LIKE '[0-9][0-9][0-9]), 
-- ,stupid_flg INTEGER NOT NULL CHECK(stupid_flg IN (0, 1)) -- drop this column! 
INSERT INTO Foobars
VALUES
(1, '001', '002', 0), 
(2, '003', '004', 0), 
(3, '009', '010', 1), 
(4, '015', '018', 1), 
(5, '019', '020', 0), 
>> so basically the fourth column (stupid_flg) is what I want to get if I am given the three columns. The flag 0 or 1 will be applied in the forth column if col_2 is not a follow up number of the previous row's col_3 value. <<
Does “follow up number” mean that we are supposed to convert the string to a numeric, and look for a successor? Is col_1 actually the key? 
Did you know that SQL is based on sets? Sets are mathematical structures which have no ordering. This whole exercise is highly suspect. What does the sequenced pair mean in  your data model?  
SELECT foobar_seq, col_2, col_3 
       CASE WHEN CAST(col_2 AS INTEGER) +1 = CAST(col_3 AS INTEGER)
            THEN 'TRUE' ELSE 'FALSE' END AS stupid_flg
  FROM Foobars;
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL

Similar Messages

  • How to identify when shd i go for lis nor for lo

    hi all,
    Can anyone explain me with a scenario to identify when shd we go for LIS extraction and we shd we opt for LO extraction.
    thanxs
    hari

    Hi Hari,
       Presently we are not using LIS, maximum we  go for LO extraction only... when  you  no need V3 update ,  and  you want to extract the entire module data ..(i mean not for a specific  application wise.. )that time you can go for LIS.. but.. for updating the data  definetly maximem  we need only V3 update. so, always suggestable is LO extraction..   Previously we dont have Lo extraction.that time  we   go for  LIS..
    thansk
    @jay

  • Final Cut Pro 5 doesn't capture when there's a break in time code

    Hi,
    I'm trying to capture a mini DV tape using "Capture Now". When it encounters a break in time code, FCP stops the deck and the capture -- which is what I want it to do -- but I don't get a media file in my Browser window or in the Capture Scratch folder of the footage that should have been captured up until the break. What could the problem be & what is my fix-it?
    Thanks for any/all help!
    Natascha

    Check the settings in User Preferences (General tab). The "On timecode break:" popup menu should be set to "Make New Clip" or "Warn After Capture". If its set to "Abort Capture" nothing will be saved.

  • ALV: OOPS: How to identify when the BACK button is hit?

    Hi All,
    I have a requirement in which when the BACK button on the ALV output is hit, i have to leave to the Original Selection Screen.
    I know that using SET SCREEN 0. this can be done. But i'm unable to find the point at which the Event about the BACK button is triggered.
    How can i identify if the button hit was the back button?
    Thanks in advance,
    Jr.

    Hi Jr,
    u declare sy-ucomm in data decla.
    in code try this out.
    Case sy-ucomm.
    when 'BACK'.
    leave to screen#. " # For the selection screen (i dnt think it is 0).
    u obviously have to set the PF status for the same by SE41 and in Aplication, u give name as BACK for the back symbol.
    I hope is will help.
    Reward if useful
    Thanks
    Sujay

  • How data update when there is two planning cubes in one aggregation level

    If we have two planning cubes and a multi-cube includes these two planning cubes.
    then we have the aggregation level defined based on this multi-cube.
    if the characteristics and key figures defined in aggregation level all are included in these two planning cubes. When we plan the data with plan query based on this aggregation level, which plan cube will be updated with plan data, or both of them?

    HI Wang,
    yes as Bindu said you need to restrict the layout based on the infoprovider.
    Lets assume that we have a multi provider M1 and it has two planning cubes cube1 and cube1.
    in case u develop a layout for updating cube 1 give the restriction in the filter section as infoprovider = cube1.
    or the vice versa.
    Else ur layout must input values for both the cubes simultaneously, then in that case create two restricted KF with each having a restriction for cube1 and cube 2.
    so wen the user enters value for the first restricted KF it will get saved in cube1 and wen he enters value for the second  restricted KF it will gets saved in cube2.
    This is how it works. Guess this was useful to u.
    Regards.
    Shafi.

  • How to publish when there is no appstore in a country

    Hello,
    I'm working for a compagny. This group has several entities in magreb and in africa.
    We would like to publish an app (one by country) for our customers which are resident or not resident of those countries
    But in some country, there is no official appstore. For example, I do not find any appstore in Burkina.
    If i'm right, I have to define a country for the publication of our App
    So how can I do to be correctly registred ? 
    Could you help me to find a solution ?  
    thanks you
    regards,
    Helene

    Hello Helen,
    I think you'd have to contact Apple Developers site to find out...
    https://developer.apple.com/contact/

  • How to identify if there is standard datasource available for a table/view

    hi
    Is there anyway we can identify or know if a particular table/view  in r/3 already has a standard datasource on it .
    we are working on tax/insurance data   table - J_3GVERSI
    is there any std. datasource available for this table .
    we have requirement in our report - insurance data report  which gets data from the above table.
    thanks

    Hi,
    Enter your table name in SE11 and click ''Display'. Then click ''Where-Used-List'' and select Programs, Structures etc.,
    You can see wherever your table has been used.
    Carry out this activity in ECC.
    REgards,
    Suman'

  • How to know when there will be something new.

    I have a Powermac G4...and it's ok but kinda slow...not updated. In otherwords I would like a new computer (and an iPod). I'm thinking about a refurbished 20" imac intel core duo. But I don't want to get it and then realize something new just came out the next day. I know It's a method of sales, but it would be nice to know what's next like a new OS, prosessor, computer, ect. One other thing withthat is if there will be a new eMac. That would be tight.
    Power Mac G4   Mac OS X (10.3)   I'm getting a new imac/any newer computer like a new emac

    Hi Delectric! And Welcome To Discussions!
    It really doesn't matter when you buy a product, any product. There will always be something New & Improved, subsequently released!
    As per the Apple Discussions Use Agreement, you will not find posters speculating about future Apple releases/upgrades.
    Quoted:
    "2. Submissions
    -Search or browse for existing answers before you ask a question. Someone else may have asked your question — it may save you some time.
    -Stay on topic. Apple's discussion forums are here to help people use Apple products and technologies more effectively. Unless otherwise noted, don't add Submissions about nontechnical topics, including:
    -That Apple rumor you saw on another website.
    -Discussions of Apple policies or procedures.
    -Speculations/rumors about unannounced products.
    -The status of your 1973 MG Midget restoration.
    ali b

  • Identify when a user has change value in USEREXIT_CHECK_VBAP before saving

    I originally posted and closed this question, but I am still struggling with the code.
    The req is now to also update the value of VBAP-LPRIO, so I now have to use the Exit : USEREXIT_CHECK_VBAP.
    The issue is that my solution must take into account when a user manually overwrites a value and not replace it with a value determined in the user exit.
    My problem is that the user might do the following
    1 - Create a sales order and enter a new item line, press enter
    2 - The user exit is triggered, and I check that XVBAP-UPDKZ = I  (user add a new line)
    3 - The user-exit determines the new value and populates the field
    4- the user then click on the item line, and then manually changes the value of VBAP-LPRIO
    5- The user-exit is triggered again, and because  XVBAP-UPDKZ = I , my code is triggered and updates the field.
    What I want is to identify that a user has manually changed the value and not overwritte the value.
    1 - I have check YVBAP and it is blank, as the user has not saved the sales order.
    2- The values of VBAP and XVBAP are the same..
    3 - I cannot re-read the database (KNVV) table as the user could have populate the value with the same value.
    What I need is how to identify when a user has made a change to a field before they save the sales item, as YVBAP is never filled.
    Previous post----
    Hello,
    I am writing a bit of code that will overwrite the payment terms in a sales order item based on a number of factors. (ship-to, incoterms, document type, etc)
    I am using the following program MV45AFZB at Exit : USEREXIT_CHECK_VBAP. I am using this exit as the users need to see the payment terms after an item has been entered into the sales order and not have the value determined at sales order save.
    I am not using USEREXIT_MOVE_FIELD_TO_VBAP as it is only triggered once at the time of creation and not when I change the document. I need it in USEREXIT_CHECK_VBAP as users could change the incoterms in VA02, so the code must be redetermined.
    My code is working as expected, however, I have a problem when a user enters a sales order item line and then manually changes the payment terms, as my code then is over writes the users values.
    The flow is as follows
    As user creates a sales order
    They populate the sales order header
    They populate material number and qty
    User exit USEREXIT_CHECK_VBAP is triggered and correctly determines the payment terms
    The user then double clicks on the sales order item and decides to overwrite the payment terms.
    My user-exit is retriggered and check to see if XVBAP-UPDKZ = I (insert)
    As it is still an insert, my code triggers.
    I have tried to check YVBAP, but no entry exist as it stills is seen as in insert? What I really need to know that while it is still an insert, the user has change the field value and my code should not over write the users value.

    When do you need to update LPRIO ? When user makes the change at the Payment terms on line item?
    Regards,
    Naimesh Patel

  • How to know when a function is running in TRFC mode

    Hi,
    I have an RFC function and i would like the program to behave differently when called as a TRFC.
    The question is how to identify when it is being executed asynchronously rather than synchronously.
    Did I miss something obvious?
    Any suggestions?

    Actually I think this is probably solved by calling FM TRFC_RECEIVER_INFO.

  • How can you identify when a RP has a bootflash failure on CRS-1?

    Hi Everyone,
    I am hoping someone can assist me in identifying when a RP has a bootflash issue and requires RMA.  We have some CRS-1 running in our network with IOS XR 3.8.2 and some with 4.0.3.  All the commands that I am aware of do not identify when a RP has a problem in bootflash.  CCO recommends that if there is a problem with upgrade and you are moving to a code using filesystem fat 32 that you format the bootflash of the RP's.  It was at this point we started having issues.  We went into ROMMON and recieved the following error.
    rommon B1 > dir bootflash:disk0/hfr-os-mbi-4.0.3 Checksum failed on hfr-fslib-m
    Expected checksum: 6a53, calculated checksum: beba
    open: file "hfr-fslib-m" not found
    loadprog: error - on file open
    cannot load the monitor library "bootflash:%hfr-fslib-m" from device
    If someone has some insight on how we can validate the state of the RP outside of the typical command set:
    show redundancy summary
    show platform
    etc
    I'd appreciate it.
    Cheers,
    Rashmi

    Hi,
    Provide some more information on your problem.
    If you want to check the directory contect try
    dir bootflash:
    is it displaying any output?
    In general above error doesn't indicate that there is any problem but it is not able to find particular directory or file.
    Thanks
    Parthiv

  • How to find Latch and what actions need to be taken when there is a latch

    Hi
    Can you please tell me how to find Latch and what actions need to be taken when there is a latch?
    Thanks
    Regards,
    RJ.

    1. What is a latch?
    Latches are low level serialization mechanisms used to protect shared
    data structures in the SGA. The implementation of latches is operating
    system dependent, particularly in regard to whether a process will wait
    for a latch and for how long.
    A latch is a type of a lock that can be very quickly acquired and freed.
    Latches are typically used to prevent more than one process from
    executing the same piece of code at a given time. Associated with each
    latch is a cleanup procedure that will be called if a process dies while
    holding the latch. Latches have an associated level that is used to
    prevent deadlocks. Once a process acquires a latch at a certain level it
    cannot subsequently acquire a latch at a level that is equal to or less
    than that level (unless it acquires it nowait).
    2. Latches vs Enqueues
    Enqueues are another type of locking mechanism used in Oracle.
    An enqueue is a more sophisticated mechanism which permits several concurrent
    processes to have varying degree of sharing of "known" resources. Any object
    which can be concurrently used, can be protected with enqueues. A good example
    is of locks on tables. We allow varying levels of sharing on tables e.g.
    two processes can lock a table in share mode or in share update mode etc.
    One difference is that the enqueue is obtained using an OS specific
    locking mechanism. An enqueue allows the user to store a value in the lock,
    i.e the mode in which we are requesting it. The OS lock manager keeps track
    of the resources locked. If a process cannot be granted the lock because it
    is incompatible with the mode requested and the lock is requested with wait,
    the OS puts the requesting process on a wait queue which is serviced in FIFO.
    Another difference between latches and enqueues is that
    in latches there is no ordered queue of waiters like in enqueues. Latch
    waiters may either use timers to wakeup and retry or spin (only in
    multiprocessors). Since all waiters are concurrently retrying (depending on
    the scheduler), anyone might get the latch and conceivably the first one to
    try might be the last one to get.
    3. When do we need to obtain a latch?
    A process acquires a latch when working with a structure in the SGA
    (System Global Area). It continues to hold the latch for the period
    of time it works with the structure. The latch is dropped when the
    process is finished with the structure. Each latch protects a different
    set of data, identified by the name of the latch.
    Oracle uses atomic instructions like "test and set" for operating on latches.
    Processes waiting to execute a part of code for which a latch has
    already been obtained by some other process will wait until the
    latch is released. Examples are redo allocation latches, copy
    latches, archive control latch etc. The basic idea is to block concurrent
    access to shared data structures. Since the instructions to
    set and free latches are atomic, the OS guarantees that only one process gets
    it. Since it is only one instruction, it is quite fast. Latches are held
    for short periods of time and provide a mechanism for cleanup in case
    a holder dies abnormally while holding it. This cleaning is done using
    the services of PMON.
    4. Latches request modes?
    Latches request can be made in two modes: "willing-to-wait" or "no wait". Normally,
    latches will be requested in "willing-to-wait" mode. A request in "willing-to-wait" mode
    will loop, wait, and request again until the latch is obtained. In "no wait" mode the process
    request the latch. If one is not available, instead of waiting, another one is requested. Only
    when all fail does the server process have to wait.
    Examples of "willing-to-wait" latches are: shared pool and library cache latches
    A example of "no wait" latches is the redo copy latch.
    5. What causes latch contention?
    If a required latch is busy, the process requesting it spins, tries again
    and if still not available, spins again. The loop is repeated up to a maximum
    number of times determined by the initialization parameter SPINCOUNT.
    If after this entire loop, the latch is still not available, the process must yield
    the CPU and go to sleep. Initially is sleeps for one centisecond. This time is
    doubled in every subsequent sleep.
    This causes a slowdown to occur and results in additional CPU usage,
    until a latch is available. The CPU usage is a consequence of the
    "spinning" of the process. "Spinning" means that the process continues to
    look for the availability of the latch after certain intervals of time,
    during which it sleeps.
    6. How to identify contention for internal latches?
    Relevant data dictionary views to query
    V$LATCH
    V$LATCHHOLDER
    V$LATCHNAME
    Each row in the V$LATCH table contains statistics for a different type
    of latch. The columns of the table reflect activity for different types
    of latch requests. The distinction between these types of requests is
    whether the requesting process continues to request a latch if it
    is unavailable:
    willing-to-wait If the latch requested with a willing-to-wait
    request is not available, the requesting process
    waits a short time and requests the latch again.
    The process continues waiting and requesting until
    the latch is available.
    no wait If the latch requested with an immediate request is
    not available, the requesting process does not
    wait, but continues processing.
    V$LATCHNAME key information:
    GETS Number of successful willing-to-wait requests for
    a latch.
    MISSES Number of times an initial willing-to-wait request
    was unsuccessful.
    SLEEPS Number of times a process waited a requested a latch
    after an initial wiling-to-wait request.
    IMMEDIATE_GETS Number of successful immediate requests for each latch.
    IMMEDIATE_MISSES Number of unsuccessful immediate requests for each latch.
    Calculating latch hit ratio
    To get the Hit ratio for latches apply the following formula:
    "willing-to-wait" Hit Ratio=(GETS-MISSES)/GETS
    "no wait" Hit Ratio=(IMMEDIATE_GETS-IMMEDIATE_MISSES)/IMMEDIATE_GETS
    This number should be close to 1. If not, tune according to the latch name
    7. Useful SQL scripts to get latch information
    ** Display System-wide latch statistics.
    column name format A32 truncate heading "LATCH NAME"
    column pid heading "HOLDER PID"
    select c.name,a.addr,a.gets,a.misses,a.sleeps,
    a.immediate_gets,a.immediate_misses,b.pid
    from v$latch a, v$latchholder b, v$latchname c
    where a.addr = b.laddr(+)
    and a.latch# = c.latch#
    order by a.latch#;
    ** Given a latch address, find out the latch name.
    column name format a64 heading 'Name'
    select a.name from v$latchname a, v$latch b
    where b.addr = '&addr'
    and b.latch#=a.latch#;
    ** Display latch statistics by latch name.
    column name format a32 heading 'LATCH NAME'
    column pid heading 'HOLDER PID'
    select c.name,a.addr,a.gets,a.misses,a.sleeps,
    a.immediate_gets,a.immediate_misses,b.pid
    from v$latch a, v$latchholder b, v$latchname c
    where a.addr = b.laddr(+) and a.latch# = c.latch#
    and c.name like '&latch_name%' order by a.latch#;
    8. List of all the latches
    Oracle versions might differ in the latch# assigned to the existing latches.
    The following query will help you to identify all latches and the number assigned.
    column name format a40 heading 'LATCH NAME'
    select latch#, name from v$latchname;

  • How can I eliminate delays in one NIC when there is traffic on second NIC

    Using LabVIEW TCP/IP VIs, my LV application is  accessing a database though a LAN, and  through a second NIC, it is controlling an instrument.  The instrument is connected directly to the computer NIC with a cross-over cable.  I have made a permanent route for the IP address of the instrument in the IP route table.  The LAN and the instrument have different subnet numbers.  Using a packet sniffer, I don't see any traffic meant for the LAN going to the NIC connected to the instrument.  The OS of the computer is Windows XP and the NICs are PCI cards.
    The message traffic to the instrument suffers from intermittent delays when there is traffic going to the LAN. 
    How can I eliminate the delays?  What could be the cause of the delays?  Thanks in advance for your recommendations and suggestions.

    Hi LabBard,
    Could you tell us a little more about the device that you are connected to? What you could try is to have a VI accessing the LAN, and a separate VI communicating with the instrument, and see how things play out.
    Let us know how it goes!
    Rasheel

  • How to find port number , when there will be different instance number ?

    In case of portal url,
    port number is 50000 for default instance number 00.
    how to find port number , when there will be different instance number , instead of 00?
    Thanks

    Hi
    You can find the port number by your instance number as follows:
    There is a general format for the port number like you have mentioned.
    For 00 instance the port number is 50000.
    The general format for the port number goes like this:
        <b>5<instance_no>00</b>
    If your <b>instance number is 01</b> then the port number would be <b>50100</b>.
    It depends on the installation type which you perform.
    You can also change the instance number during the installation but normally you dont do this.
    If you have many components or units installed on your system you may have more than one instance in that case it may go like this 00, 01, 02....accordingly port number will be 50000, 50100, 50200...resp.
    Hope this solves your doubt.
    If you need some more clarification please lemme know.
    Regards
      Sumit Jain
    **Rewrd with points if useful.

  • How to change the default JRE when there are several version of JRE in Sys

    How to change the default JRE when there are several version of JRE in System?
    i have installed j2sdk1.5.0 then installed j2ee1.4,then installed Weblogic6.1 which use jdk1.3
    Now the JRE is jdk1.3\bin
    When run class that was compiled with jdk1.5,throw:
    java.lang.UnsupportedClassVersionError
    How can i change the jre to 1.5?

    There is a workaround to move from 1.5 version to the older 1.4 version. But this could be specific to the browser setting the JRE version.
    Excerpts from sun docs:
    However, a user can still run older versions. To do so, launch the Java Plug-in Control Panel for the older version, then (re)select the browser in the Browser tab.
    Example:
    Assume you are running on Microsoft Windows with Microsoft Internet Explorer, have first installed version 1.4.2, then version 5.0, and you want to run 1.4.2.
    Go to the j2re1.4.2\bin directory where JRE 1.4.2 was installed. On a Windows default installation, this would be here: C:\Program Files\Java\j2re1.4.2\bin
    Double-click the jpicpl32.exe file located there. It will launch the control panel for 1.4.2.
    Select the Browser tab. Microsoft Internet Explorer might still appear to be set (checked). However, when 5.0 was installed, the registration of the 1.4.2 JRE with Internet Explorer was overwritten by the 5.0 JRE.
    If Microsoft Internet Explorer is shown as checked, uncheck it and click Apply. You will see a confirmation dialog stating that browser settings have changed.
    Check Microsoft Internet Explorer and click Apply. You should see a confirmation dialog.
    Restart the browser. It should now use the 1.4.2 JRE for conventional APPLET tags.
    Details are here
    http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/jcp.html
    My system (Windows XP) has the version 1.5_09 set as the default. However i just installed JRE 1.5_06 and would like to revert back to _06 as the default JRE..
    Will update if i find more information

Maybe you are looking for