Fetching changes for a given query

Hi,
I have an application that uses a query to retrieve thousands of
rows.
Initially, the application fetches all the rows. After that, the application
has to fetch only the changed rows. This can be done by using a date
column that contains the Last Update Time and adding a date condition to
the query. Something like (pseudo code):
Select * from myTbl t
where t.name like '%john%'
and lastUpdateTime > current_date - (5 seconds)
In the solution above, the application gets the updated rows (in the last 5
seconds). But the application does not know which rows have been deleted
and which rows don't meet the condition.
In the given example, initially, the application has all the rows, then, when
trying to get the changes, the application don't get a row that its "name"
has been changed to 'foo'. Thus the app still displays this rows and doesn't
know that this row is not valid due to the name change (The row doesn't
meet the query condition).
Do you have any idea how to get correct changes for a given query periodically?
Thanks
Dyahav

You either have to audit your data e.g. with triggers, so that whatever changes happen are logged and you can query that record of changes to determine what happened or, you can keep a copy of the data at the previous time of querying and compare that to the current set of data to determine what has changed. e.g. if you have your "historic" data and your "current" data you would do..
select * from historic
minus
select * from currentwhich would give you deleted and updated records (let's call them "du")
then
select * from current
minus
select * from historicwhich would give you inserted and updated records (let's call them "iu")
then
select +primary_key_cols+ from iu
intersect
select +primary_key_cols+ from duwhich would give you the primary keys of all the updated rows (let's call them "u")
then
select +primary_key_cols+ from iu
minus
select +primary_key_cols+ from uwhich will give you the primary keys of all the inserted rows
and finally..
select +primary_key_cols+ from du
minus
select +primary_key_cols+ from uwhich will give you the primary keys of all the deleted rows
So, then when you have all the primary keys for the "inserted", "deleted", "updated" rows you can identify them and process them as required.
If you actually want to know what columns have changed on updated rows then you're going to have to code it to check column by column (perhaps using a decode statement), as required.

Similar Messages

  • How to trace the RevTrac carrying changes for a given system table?

    Hi everyone!
    In our company we have a case of a change no one in the team states to have done, therefore we do not know the RevTrac number that carries the changes. Currently, the development system is different from the QA, staging and production systems for our ERP.
    Is there a transaction/program that traces changes for a given table and field specified accross a given environment-client?

    HI Nicolas,
    I chatted with Rev-Trac support earlier today and here is what they have come back to me with.
    Assuming the change in question was carried out in the development  system. Changes to fields in tables should in most cases be captured in transports. Assuming it was a transportable change then go to the development system and execute transaction SE16 and query Rev-Trac table /RSC/T_MFM_4T filtering by TABLENAME.
    On executing the query you should see a list of transports involved with changes to the transport. You can then check to see if there is a recent transport associated with the change - if so then you can find out who created the transport by using standard SAP functionality."
    If you find this doesn't help, then please contact your Rev-Trac Administrator who can then log a support request on our support portal at www.xrsc.com
    Hope this helps, Rick

  • Extract the "bind" variables for a given query running in 10g.

    how can we extract the "bind" variables for a given query running in 10g? The performance of a query may vary based on the parameters supplied to it. For example, a query like the following
    SELECT * FROM CUSTOMER_ORDERS WHERE CUSTOMER = :CUST_ID
    .might run differently when the :CUST_ID is "123" who may have very few orders versus "456" who may have tens of thousands of orders.
    So, if we see a spike in the system due to a query, we need visibility into what the exact query syntax and values are for any database session. We're aware of an Oracle view called V$SQL_BIND_CAPTURE, but what we're finding with this view is that it's only a snapshot of variables that are refreshed on an interval. That view does not give us a live view into what values are being used in the various sessions in realtime.
    If someone ould provide us with some SQL (or other means) to do get a realtime view into the SQL and variables currently running in the database, it would be greatly appreciated.

    In addition to what's been said in the other thread, you could add a layer of logging either in the database or out.
    v$sql_bind_capture and the associated ash view dba_hist_sqlbind contain sample data.
    You could up the sample rate but it's not advisable - it's still just a sample.
    If you're on 11g, this is where adaptive cursor sharing might help.
    Not help in finding the values of your binds, but help in using different plans where there is such a skew for different bind values and the plan is perhaps wrong for customer 456.
    The problem when you're got such a skew and you're using bind variables is that the two don't really go together.
    When the query is next parsed and you've got bind variable peeking enabled, you might get the 123 plan is that is the bind value at parse time and then run into problems for 456 or even vice versa.
    See http://jonathanlewis.wordpress.com/2009/05/06/philosophy-1/ for a discussion on binds and histograms which reflects the reasons for using either.

  • Update Field On Change For A SQL Query (updateable report)

    Hi,
    I'd like to request help from anyone with ideas on how to solve this.
    We are using APEX 4.2, 10GR2, RedHat5.
    I have a report that comes from SQL Query (updateable report).
    I'm using the apex_item.text and apex_item.hidden on fields.
    I'm using a button to submit and after submit process to add some logic that I need.
    There could be 1 - 10 records in the report.
    There is only 1 field that is needed to enter a value, but the value of this field determines the value of another field.
    I think that I can do this with a submit button and an after submit process where I loop through all the records. I think I have this handled.
    This is the question
    When the value of that field is changed then the value of another field in the same row changes immediately.
    Is this possible?
    All the examples I've seen so far are for a single record and that doesn't work for us.
    I guess this is a MRU process but I haven't seen an example where a dynamic action is possible on a Multi Row Update.
    Could anyone direct me to where I can see an example or help me get directions?
    I appreciate all your help an comments and I thank you in advance.

    Yes why not...what you looking for is a ajax call
    See {message:id=10390979}
    Please note:-you can also do this as a dynamic action as shown below
    Event: Change
    Selection type: jQuery Selector
    jQuery Selector: input[name="f01"]
    True action with Execute JavaScript Code and put all code inside the test funtion, you may need to amend the code to use this.triggeringElemnt in place of this

  • How to find the name of query for a given report

    Hi All,
    I am having the name of a report and i need to find out the name of query for that report . Plz tell me how to find out the name of the query for a given report.
    Thanks.
    Regards,
    Pooja Joshi.

    Use this FM
    RSAQ_DECODE_REPORT_NAME
    This FM takes program name as I/P and gives Query Name as O/P.
    This FM uses the structure AQADEF to fetch the data.
    Hope this helps.
    Regards
    Vinayak

  • How to change the fetch size for a one-to-many relationship

    With Toplink 10.1.3, since using scrollablecursor is a prerequisites for changing the fetchsize on a query (using the setFetchSize), I am wondering if it would be possible to change the fetchsize of the query which is associated to a one-to-many relationship.
    So, is this possible? How ?

    In TopLink 10.1.3 you can set the fetch-size on any query, it has nothing to do with using a ScrollableCursor.
    Example:
    readQuery.setFetchSize(100);
    To set the fetch size on a mapping query use,
    mapping.getSelectionQuery().setFetchSize(100);
    In 10.1.3 you can only set this in code, not currently through XML or the Mapping Workbench. In 10.1.3.1 you should be able to set the value through XML as well.

  • Fetch Report Program names for a given Package

    Hi,
       I need to fetch all the report program names for a given pakage. I tired TADIR table but couldnt fetch report details alone..
    thanks,
    sri
    Moderator message: very basic, please do more own research before asking, e.g. look at a few TADIR entries of different object types, also discover the repository information system.
    Edited by: Thomas Zloch on Feb 23, 2011 2:56 PM

    Dan is right to be cautious, i've seen this cause problems.
    It's not very difficult to make the chnages in BCS, and if you have a lot of them/frequent changes, you can always use create an upload method
    and then make all future changes by .txt file

  • How to query a item stock quantity for a given date

    Hi there,
    I need to query the stock quantity of an item for a given date. For example, i want to know how many pieces of A i have on stock at the 20th of march 2009.
    I know there is a report, but i need the value for a subquery.
    Regards Steffen

    Sorry Gordon,
    Your query is not wrong, far from me to insult your work. It does indeed make full sense if the business process allows the item description to change.
    If not, we can avoid a "inner join"  = smaller, cleaner and (theoritically) faster query
    Here is your code with the little review:
    SELECT T0.ItemCode, T0.Dscription, sum(T0.InQty - T0.OutQty) as 'On Hand'
    FROM DBO.OINM T0
    WHERE T0.DocDate <= '[%0]' and T0.ItemCode = '[%1]'
    GROUP BY T0.ItemCode, T0.Dscription
    Cheers
    tested on 2007 SP00 PL46

  • Error when changing a Company Code for a given Cost Center

    Hello Friends ,
                             I'm trying to modify a company code value for a given cost center in KS02 and I get the below error. The error message receommends to change the analysis period ( not sure what it is..) but when I click edit > Analysis period from tool bar I  still get the below message , is there way to get over come this issue ?
    Thanks in advance ,
    Field change Company Code is not possible (transaction data already exists)
    Message no. KS134
    Diagnosis
    To ensure the consistency of existing data, you can only change object Company Code if no transaction data exists in the change period; that is, neither plan data nor actual data has been posted.
    As transaction data already exists, it is not possible to change objects in this time period.
    Procedure
    If you still want to change the object, select a suitable change interval by choosing "Edit -> Analysis period...".

    Thank you Vishal . I have 3 cost centers with 2 having validity period ( from 01/01/1950 to 12/31/9999) and third one had 2 records 12/30/2004 to 12/26/2009 and 12/27/2009 to 12/31/9999 ) for the third one it did allow to change the validty period and I could change the comapny code for my profit center . But for first 2 somehow it doesnt allow to change the validity periods. And when I run some reports against these 2 cost centers to see if there is any activity I dont see any data .
    Could you please give your ideas ?
    Thanks alot .

  • Change Amount depending on number of decimals for a given currency

    Hi All,
    I have a requirement to change the amount field based on the number of decimals.
    I am using 'BAPI_CURRENCY_GETDECIMALS' to get the number of decimals for the given currency.
    I am having an amount field(say 3000.00), that needs to be changed.
    In our case, we have to change the amount field if the decimals are less or great than 2.
    Eg:
    Suppose, if no.of decimals is 2, then the same amount should be returned, i.e., 3000.00.
    If the number of decimals is 1, then the amount value should be multiplied by 10, that is 30000.0 should be returned. If the number of decimals is 0, then the amount value should be multiplied by 100, that is 300000 should be returned.
    If the number of decimals is 3, then the amount value should be divided by 10, that is 300.000 should be returned. If the number of decimals is 4, then the amount value should be divided by 100, that is 30.0000 should be returned and so on.
    Any pointers would be helpful..
    Thanks & Regards
    Gowthami

    Hi All,
    This logic works fine for multiplication. But checking conditions for decimals > 2 would involve many conditons.
    I think this can be achieved by two ways.
    First way is by concatenating number of zeros to 1 depending on decimals and either by dividing or multiplying the values by checking the condition.
    Second way is by shifting the decimal point either left or right depending on the decimals.
    Please help me in implementing the above.
    Thanks & Regards
    Gowthami

  • How do I change which application is the (default) for a given file type?

    For .pdf files, I have set the application behaviour to "Always Ask", because sometimes I want to open the pdf, sometimes I want to save it. So far so good.
    Now, when I want to open the .pdf, I have added an application to the dropdown list, so now I have "Adobe Reader 9 (default)" and "okular".
    The problem is this: I *never* open using Adobe Reader. I always want to use okular, but Adobe Reader always appears first on the list, as it is the 'default'. This means I always have to click on the dropdown and select "okular", i.e. an extra step every time I want to open a pdf.
    How do I change which application is the default?

    Yes, I know that. That was the first sentence of my question, but it is not the problem I have.
    I want to change which application is the (default) for a given file type, and this cannot be done from the settings.

  • Query to retrieve list of ledgers accessible for a given Applications User

    We've a requirement to find the list of the accessible ledgers for a given Oracle Apps User.I'm from Oracle ATG team,not familiar with GL terminologies. Can someone help with the query to retrieve the ledgers accessible for a given user.In our code flow, we may not have the complete applications context. Is it possible to retrieve that list only with the username. If so, how to do that? Do i need to access some profile values?
    Thanks,
    Senthil

    select * from usr where usr.usr_key not in (
    select usr.usr_key from oiu, usr, obi, obj, ost
    where oiu.usr_key=usr.usr_key
    and oiu.obi_key=obi.obi_key
    and obi.obj_key=obj.obj_key
    and obj.obj_name = :obj_name
    and oiu.ost_key=ost.ost_key
    and ost.ost_status not in ('Revoked'))
    -Kevin

  • Howto Refresh SAP BW Query Changes for roles (User menu)

    Hi All,
    I have apply new changes for combine hierarchy. However I have tested in Query Designer/web and its works ok hence the user cant see the change.
    Howto Refresh SAP BW Query Changes for roles (User menu)
    Below is the setup we do have (sap bw 3.5)
    1. User run query from User menu (They logon to bw backend and run query by click on the icon on thier user menu.
    Changes.
    1.Apply combine hierarchy (Rows in Query Designer)
    2. I have display query on the web and its work as expect
    Issue
    1. Query not refresh in user menu (Roles) Users run the query through user menu
    Regards Jon

    thank you

  • SQL Query to search all the tables for a given string

    Hi all,
    This is concerning a query to search each and every table/column for a given string.
    I came across a similar post (Re: question about searching 600 tables and this query seems to be inline with my requirements:
    select table_name,
    column_name,
    :search_string search_string,
    result
    from cols,
    xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| :search_string || '%") > 0]')
    columns result varchar2(10) path '.'
    where table_name in ('MY_TABLE')
    However, I am getting the following error:
    ORA-24451: OCIKCallPushTrusted, Maximum call depth exceeded
    I am using Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit and could you please let me know the best possible way to accomplish this task?
    Thanks.
    Edited by: itech.quest on Sep 19, 2010 8:30 AM

    Hi Tamir,
    Thanks so far. I am yet to make the crucial breakthrough as far my application goes. Are you talking about the EUL5_QPP_STATS table? I tried retrieving worksheets even from that table also with the following query
    SELECT DISTINCT Eul5QppStats.QS_DOC_NAME,Eul5QppStats.QS_DOC_DETAILS
    FROM EUL5_QPP_STATS Eul5QppStats,EUL5_DOCUMENTS Eul5Documents
    WHERE Eul5QppStats.QS_DOC_NAME = Eul5Documents.DOC_NAME
    However, the worksheet data retrieved by Discoverer Oracle's product is not matching my dataset for every workbook. Please suggest.
    Reg
    Thomas

  • How changing the criterion for an access query in java?

    Hi @ all
    I would like to change a criterion for an access-query in java. I know how to run a access-query in java. How can I change the criterion in my access query in java without running the query it selfs? Can anybody help me?
    Thx
    Dario

    I would like to change a criterion for an
    access-query in java. I know how to run a
    access-query in java. How can I change the criterion
    in my access query in java without running the query
    it selfs? Can anybody help me?
    You can't.
    The database processes the query and then returns the result to you. Thus to change the query you must run the query again.
    You can of course add code do do the same thing. But unless it is very simple it is going to take a lot of code and might even be slower than doing the database call.

Maybe you are looking for

  • Amount in Arabic

    Hi All We have developed a Bi-lingual form (English and Arabic) with arabic as original language. we need to display a value field(amount) in arabic and english. We have amount in english like 81,321.50 . How to display amount in arabic ? Numericals

  • Best Practice for Domain Controllers for a company of 500 users.

    Our company is expanding and is planning on having roughly 500 users managed by a domain controller. The question is, what sort of hardware do you actually need that will not be a bottleneck in the near future (3-5 years from now). We stick with Dell

  • Video scrubbing iOS 8

    http://youtu.be/ZKgRsZDUt8s if u watch this video It is the same problem I have and It is annoying I've reported this to apple a few times before the updates Of 8.0.2 and 8.1 and still no fix

  • Installing 2.0 on a old iphone afer sim is remove

    Can you still install 2.0 on a old iphone that has been upgraded. The phone does not have a SIM card. Is there a charge for the software?

  • AM Client program throwing "Cannot create application SSO token"

    I am trying to run the policyevaluator client program (from both standalone and as a web app), when I run it , it throws the following exception.. com.sun.identity.policy.PolicyException: Cannot create application SSO token.      at com.sun.identity.