Best way to write the following query

Hello
I have following table structures and data...
And I wrote the request in order to obtain records that are superior to BBB-
But could you please me to write in a simpler way.
create table obj (ob_id )
as select 1 from dual union all
select 2 from dual union all
select 3 from dual union all
select 4 from dual union all
select 5 from dual union all
select 6 from dual

create table og_dt (or_id , rt_cd,rt_ct_cd)
AS SELECT 1 ,'B','BRID' FROM DUAL UNION ALL
   SELECT 1 ,'B','BRD' FROM DUAL UNION ALL
   SELECT 2 ,'BB-','ACR' FROM DUAL UNION ALL
   SELECT 2 ,'BB-','AQCR' FROM DUAL UNION ALL
   SELECT 3 ,'BBB','QYRE' FROM DUAL UNION ALL
   SELECT 4 ,'BB+','TUR' FROM DUAL UNION ALL
   SELECT 5 ,'BBB-','KUYR' FROM DUAL 
   
   
create table rt_srt (srt_ord,rt_cd,rt_ct_cd)
as select 50 ,'B','VID' FROM DUAL UNION ALL
   SELECT 50 ,'B','BRD' FROM DUAL UNION ALL
   SELECT 40 ,'BB-','ACR' FROM DUAL UNION ALL
   SELECT 41 ,'BB-','AQCR' FROM DUAL UNION ALL
   SELECT 30 ,'BBB','QYRE' FROM DUAL UNION ALL
   SELECT 33 ,'BB+','TUR' FROM DUAL UNION ALL
   SELECT 20 ,'BBB-','KUYR' FROM DUAL 
   
      
select distinct 
*
   from obj,og_dt,rt_srt
  where obj.ob_id=og_dt.or_id
  and og_dt.rt_cd = rt_srt.rt_cd
  and og_dt.rt_ct_cd=rt_srt.rt_ct_cd
and rt_srt.srt_ord > all (select rt_srt.srt_ord from rt_srt
where rt_cd='BBB-' 
I used the table rt_srt twise in the above query
Could you advice please write it in simple way.

Thank you

Here's the implementation plans for 3 possible solutions (including the one you posted). Solutions of second & third assumes that rt_srt.srt_ord is not null:

SQL> explain plan for
  2  select  distinct *
  3    from  obj,
  4          og_dt,
  5          rt_srt
  6    where obj.ob_id = og_dt.or_id
  7      and og_dt.rt_cd = rt_srt.rt_cd
  8      and og_dt.rt_ct_cd = rt_srt.rt_ct_cd
  9      and rt_srt.srt_ord > all (
 10                                select  rt_srt.srt_ord
 11                                  from  rt_srt
 12                                  where rt_cd = 'BBB-'
 13                               )
 14  /

Explained.

SQL> @?\rdbms\admin\utlxpls

PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------
Plan hash value: 3210303028

---------------------------------------------------------------------------------
| Id  | Operation              | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------
|   0 | SELECT STATEMENT       |        |     7 |   504 |    16  (25)| 00:00:01 |
|   1 |  HASH UNIQUE           |        |     7 |   504 |    16  (25)| 00:00:01 |
|   2 |   MERGE JOIN ANTI NA   |        |     7 |   504 |    15  (20)| 00:00:01 |
|   3 |    SORT JOIN           |        |     7 |   385 |    11  (19)| 00:00:01 |
|*  4 |     HASH JOIN          |        |     7 |   385 |    10  (10)| 00:00:01 |
|*  5 |      HASH JOIN         |        |     7 |   238 |     7  (15)| 00:00:01 |

PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------
|   6 |       TABLE ACCESS FULL| OBJ    |     6 |    78 |     3   (0)| 00:00:01 |
|   7 |       TABLE ACCESS FULL| OG_DT  |     7 |   147 |     3   (0)| 00:00:01 |
|   8 |      TABLE ACCESS FULL | RT_SRT |     7 |   147 |     3   (0)| 00:00:01 |
|*  9 |    SORT UNIQUE         |        |     1 |    17 |     4  (25)| 00:00:01 |
|* 10 |     TABLE ACCESS FULL  | RT_SRT |     1 |    17 |     3   (0)| 00:00:01 |
---------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   4 - access("OG_DT"."RT_CD"="RT_SRT"."RT_CD" AND

PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------
              "OG_DT"."RT_CT_CD"="RT_SRT"."RT_CT_CD")
   5 - access("OBJ"."OB_ID"="OG_DT"."OR_ID")
   9 - access("RT_SRT"."SRT_ORD"<="RT_SRT"."SRT_ORD")
       filter("RT_SRT"."SRT_ORD"<="RT_SRT"."SRT_ORD")
  10 - filter("RT_CD"='BBB-')

Note
-----
   - dynamic sampling used for this statement (level=2)

31 rows selected.

SQL> explain plan for
  2  select  distinct *
  3    from  obj,
  4          og_dt,
  5          rt_srt
  6    where obj.ob_id = og_dt.or_id
  7      and og_dt.rt_cd = rt_srt.rt_cd
  8      and og_dt.rt_ct_cd = rt_srt.rt_ct_cd
  9      and rt_srt.srt_ord > (
 10                            select  max(rt_srt.srt_ord)
 11                              from  rt_srt
 12                              where rt_cd = 'BBB-'
 13                           )
 14  /

Explained.

SQL> @?\rdbms\admin\utlxpls

PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------
Plan hash value: 3391900174

---------------------------------------------------------------------------------
| Id  | Operation              | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------------
|   0 | SELECT STATEMENT       |        |     1 |    55 |    14  (15)| 00:00:01 |
|   1 |  HASH UNIQUE           |        |     1 |    55 |    14  (15)| 00:00:01 |
|*  2 |   HASH JOIN            |        |     1 |    55 |    10  (10)| 00:00:01 |
|   3 |    MERGE JOIN CARTESIAN|        |     2 |    68 |     6   (0)| 00:00:01 |
|*  4 |     TABLE ACCESS FULL  | RT_SRT |     1 |    21 |     3   (0)| 00:00:01 |
|   5 |      SORT AGGREGATE    |        |     1 |    17 |            |          |

PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------
|*  6 |       TABLE ACCESS FULL| RT_SRT |     1 |    17 |     3   (0)| 00:00:01 |
|   7 |     BUFFER SORT        |        |     6 |    78 |     3   (0)| 00:00:01 |
|   8 |      TABLE ACCESS FULL | OBJ    |     6 |    78 |     3   (0)| 00:00:01 |
|   9 |    TABLE ACCESS FULL   | OG_DT  |     7 |   147 |     3   (0)| 00:00:01 |
---------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("OBJ"."OB_ID"="OG_DT"."OR_ID" AND
              "OG_DT"."RT_CD"="RT_SRT"."RT_CD" AND

PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------
              "OG_DT"."RT_CT_CD"="RT_SRT"."RT_CT_CD")
   4 - filter("RT_SRT"."SRT_ORD"> (SELECT MAX("RT_SRT"."SRT_ORD") FROM
              "RT_SRT" "RT_SRT" WHERE "RT_CD"='BBB-'))
   6 - filter("RT_CD"='BBB-')

Note
-----
   - dynamic sampling used for this statement (level=2)

30 rows selected.

SQL> explain plan for
  2  select  distinct obj.*,
  3                   og_dt.*,
  4                   rt_srt.srt_ord,
  5                   rt_srt.rt_cd,
  6                   rt_srt.rt_ct_cd
  7    from  obj,
  8          og_dt,
  9          (
 10           select  t.*,
 11                   max(case rt_cd when 'BBB-' then srt_ord end) over() max_srt_ord
 12             from  rt_srt t
 13          ) rt_srt
 14    where obj.ob_id = og_dt.or_id
 15      and og_dt.rt_cd = rt_srt.rt_cd
 16      and og_dt.rt_ct_cd = rt_srt.rt_ct_cd
 17      and rt_srt.srt_ord > max_srt_ord
 18  /

Explained.

SQL> @?\rdbms\admin\utlxpls

PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------
Plan hash value: 998396165

--------------------------------------------------------------------------------
| Id  | Operation             | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------
|   0 | SELECT STATEMENT      |        |     7 |   476 |    11  (19)| 00:00:01 |
|   1 |  HASH UNIQUE          |        |     7 |   476 |    11  (19)| 00:00:01 |
|*  2 |   HASH JOIN           |        |     7 |   476 |    10  (10)| 00:00:01 |
|*  3 |    HASH JOIN          |        |     7 |   238 |     7  (15)| 00:00:01 |
|   4 |     TABLE ACCESS FULL | OBJ    |     6 |    78 |     3   (0)| 00:00:01 |
|   5 |     TABLE ACCESS FULL | OG_DT  |     7 |   147 |     3   (0)| 00:00:01 |

PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------
|*  6 |    VIEW               |        |     7 |   238 |     3   (0)| 00:00:01 |
|   7 |     WINDOW BUFFER     |        |     7 |   147 |     3   (0)| 00:00:01 |
|   8 |      TABLE ACCESS FULL| RT_SRT |     7 |   147 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("OG_DT"."RT_CD"="RT_SRT"."RT_CD" AND
              "OG_DT"."RT_CT_CD"="RT_SRT"."RT_CT_CD")
   3 - access("OBJ"."OB_ID"="OG_DT"."OR_ID")

PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------
   6 - filter("RT_SRT"."SRT_ORD">"MAX_SRT_ORD")

Note
-----
   - dynamic sampling used for this statement (level=2)

27 rows selected.

SQL> 

SY.

Published by: Solomon Yakobson on May 7, 2012 16:46

Tags: Database

Similar Questions

  • Best way to write the Pl/Sql

    Hi all
    Can someone say best written below stored proc:

    procedure missing_authorized_services is
    v_truncate_sql varchar2 (200);
    v_sql varchar2 (2000);
    BEGIN
    v_truncate_sql: = "truncate table missing_authorized_services;
    immediately run v_truncate_sql;
    commit;

    v_sql: = "INSERT into missing_authorized_services select distinct trim (service_group_Cd) as service_group_Cd, trim (service_cd) as stage_1_mg_service_request service_cd
    where (service_group_cd, service_cd) not in)
    Select distinct service_group_cd, stage_3_servcd_servgrp_dim service_cd)';

    immediately run v_sql;
    commit;

    END missing_authorized_services;


    / * I do select the table and then try to insert into another table the result set * /.

    Please help,
    Thank you
    J

    Hello

    The best way to write the PL/SQL (or any code) is by small steps.
    Start with a very simple procedure that does something (anything), just enough to make sure it works.
    Add a lot of statements of output so you can see what made the procedure. Don't forget to delete them after that trial is over.

    For example:

    CREATE OR REPLACE procedure missing_authorized_services IS
            v_truncate_sql  VARCHAR2 (200);
    BEGIN
         v_truncate_sql := 'truncate table missing_authorized_services';
         dbms_output.put_line (  v_truncate_sql
                        || ' = v_truncate_sql inside missing_authorized_services'
                        );
    END      missing_authorized_services;
    

    If you get any errors (for example, ORA-00955, because you try to give the same name to a procedure that you already use for a table), then fix the error and try again.
    When he worls perfectly, then add another baby step. For example, you can add the line

    EXECUTE IMMEDIATE v_truncate_sql;
    

    and test again.

    Do not use SQL dynamic (EXECUTE IMMEDIATE) unless you have to.
    Is there a reason to use dynamic SQL for INSERT statements?

  • Better way to write the simple query?

    I'm trying to get the date of 'busy' max 'mansion '.

    It is an example, I imagined, since I can't post our actual data. The following query works, but is their path easier.
    CREATE TABLE TEST_TABLE (  
    LOAN_NUMBER                 VARCHAR2(15 Byte),
    UN_ID                       NUMBER,
    CHANGE_DATE                 DATE,
    PROP_TYPE                   VARCHAR2(25 Byte),
    OCCSTAT                     VARCHAR2(25 Byte)
    ); 
    COMMIT;
    
    
    INSERT INTO TEST_TABLE VALUES (123456,  1,'01-JAN-09','Tent','Occupied');
    INSERT INTO TEST_TABLE VALUES (123456,  2,'01-FEB-09','Shack','Occupied');
    INSERT INTO TEST_TABLE VALUES (123456,  3,'01-JUN-08','Single Family','Occupied');
    INSERT INTO TEST_TABLE VALUES (123456,  4,'01-OCT-08','Single Family Plus','Occupied');
    INSERT INTO TEST_TABLE VALUES (123456,  5,'01-DEC-08','Mansion','Occupied');
    INSERT INTO TEST_TABLE VALUES (123456,  6,'05-JAN-09','Mansion','Unoccupied');
    COMMIT;
    Reason, I take the ID's for the second join because I know that the ID max = max.
    select     
    i2.UN_ID,
    i2.CHANGE_DATE,
    i2.PROP_TYPE,
    i2.OCCSTAT
    from 
    (
        select 
            distinct(LOAN_NUMBER) AS "LOAN_ID", 
            max(UN_ID) AS "ID_MAX"
        from(
        select 
            LOAN_NUMBER,
            UN_ID
      from
            TEST_TABLE
        where OCCSTAT = 'Occupied'
        group by LOAN_NUMBER, UN_ID
        ) 
        group by LOAN_NUMBER
    )i
    left join TEST_TABLE i2 on i.ID_MAX = i2.UN_ID
    easier way without the second join?

    Thanks in advance.

    R

    Try this query, it should be equivalent to your:

    select UN_ID, CHANGE_DATE, PROP_TYPE, OCCSTAT
    from (
        select LOAN_NUMBER, UN_ID, CHANGE_DATE, PROP_TYPE, OCCSTAT, rank() over(partition by LOAN_NUMBER order by un_id desc) rn
        from test_table
         where OCCSTAT = 'Occupied'
    )
    where rn=1
    

    Max

  • Best way to write the earpiece button code?

    Hello

    I'm trying to update several fields when the user clicks a button. I have a meter static val in a separate category that determines what value is displayed when you click a field. Why should I do the final BigVector? I thought I should be impossible to add elements once a var has been marked as final? Is there a better way to achieve what I'm doing?

    Here is my code, thank you--

    final BigVector bigStringVectorA = new BigVector();
    bigStringVectorA.addElement ("a response 1 Test");
    bigStringVectorA.addElement ("a 2 response Test");
    bigStringVectorA.addElement ("a response 3 Test");

    aAnswerOptionButton.setChangeListener (new FieldChangeListener() {}
    ' Public Sub fieldChanged (field field, int context) {}
    ++ Constants.counter;
    aAnswerOptionButton.setText ((String) bigStringVectorA.elementAt (Constants.counter));
    bAnswerOptionButton.setText ((String) bigStringVectorB.elementAt (Constants.counter));
    cAnswerOptionButton.setText ((String) bigStringVectorC.elementAt (Constants.counter));
    }
    });

    If you set bigStringVectorA as a class attribute you won't have to make it final.

  • best way to write this query

    Hello

    I have a problem and I realized a simplified version of it:

     
    
    create table deals (id_prsn number, id_deal number, fragment number); 
    create table deal_values (id_prsn number, id_deal number, value_ number, date_ date); 
    
    insert into deals values(1,1,50); 
    insert into deals values(2,2,40); 
    insert into deals values(1,3,50); 
    insert into deals values(2,4,80); 
    insert into deals values(1,5,20); 
    insert into deals values(2,6,80); 
    
    insert into deal_values values(1,1,10 ,sysdate - 3); 
    insert into deal_values values(2,2,208, sysdate - 3); 
    insert into deal_values values(2,4,984, sysdate - 3); 
    insert into deal_values values(1,null,134,sysdate - 3); 
    insert into deal_values values(1,1,13, sysdate - 2); 
    insert into deal_values values(2,2,118, sysdate - 2); 
    insert into deal_values values(2,4,776, sysdate - 1); 
    insert into deal_values values(1,null,205,sysdate - 1); 
    insert into deal_values values(2,null,-5,sysdate - 1); 
    The id of the requirement to join these two tables based on:

    1.) ID_PRSN and ID_DEAL
    2.) max DATE_ grouped per person and deal
    (3.) in the case that ID_DEAL is defined in the AGREEMENTS, but not defined in the DEAL_VALUES table, I have to join this records to DEAL_VALUES based on the person where id_Deal is null.

    Number 3 gives me headache. I realized the following query:
     
    
    select *from ( 
    select a.id_prsn, 
           a.id_deal, 
           a.fragment, 
           b.value_, 
           b.date_, 
           max(b.date_) over (partition by b.id_prsn, b.id_deal) max_date 
      from deals a 
    inner join deal_values b 
        on a.id_deal = b.id_deal or b.id_deal is null 
       and not exists  (select 1 from deal_values 
                                  where id_prsn = a.id_prsn 
                                    and id_deal = a.id_deal) 
       and a.id_prsn = b.id_prsn 
    ) 
    where date_ = max_Date; 
    It returns the correct result of he,


    ID_PRSN ID_DEAL FRAGMENT VALUE_ DATE_ MAX_DATE
    1 1 50 13 16.10.2012 09:59:48 16.10.2012 09:59:48
    1 3 50 205 17.10.2012 09:59:48 17.10.2012 09:59:48 OK
    1 5 20 205 17.10.2012 09:59:48 17.10.2012 09:59:48 OK
    2 2 40 118 16.10.2012 09:59:48 16.10.2012 09:59:48
    2 4 80 776 17.10.2012 09:59:48 17.10.2012 09:59:48
    2 6 80-5 17.10.2012 09:59:48 17.10.2012 09:59:48 OK



    but the join clause:
     
    
    
        on a.id_deal = b.id_deal or b.id_deal is null 
       and not exists  (select 1 from deal_values 
                                  where id_prsn = a.id_prsn 
                                    and id_deal = a.id_deal) 
       and a.id_prsn = b.id_prsn 
    in fact the query much slower.

    I was wondering is there a different way to write this join and manage the logic.

    Thanks in advance

    Here's a different approach:

    select * from (
      select a.id_prsn, a.id_deal, a.fragment, B.value_, b.date_,
      ROW_NUMBER() over(
        partition by a.ID_PRSN, a.ID_DEAL
        order by B.ID_DEAL nulls last, B.DATE_ desc
      ) RN
      from DEALS a
      join DEAL_VALUES B
      on a.ID_PRSN = B.ID_PRSN and a.ID_DEAL = NVL(B.ID_DEAL, a.ID_DEAL)
    )
    where rn = 1
    order by 1, 2;
    

    "nulls last" is the default sort order; I just put that for clarity.

    Published by: stew Ashton on October 18, 2012 12:58

  • AS3 on Flash CC - best way to write text on a curved path? to rotate the text?

    AS3 on Flash CC - best way to write text on a curved path? to rotate the text?

    you need to incorporate your policy.

  • What is the best way to optimize a SQL query: call a function or doing a join?

    Hi, I want to know what is the best way to optimize a SQL query, call a function inside the SELECT statement, or make a simple join?

    It depends on.  Could be a.  Could be the other.  Could be no difference.  You would need to compare with your tables in your environment with your settings.

    If you put a gun to my head, I was given no other information and required that I answered the question, I would tend to wait that the join would be more effective.  In general, if you can do something in pure SQL, it will be more effective than if you call PL/SQL.

    Justin

  • Best way to update the individual rows of a Table?

    I took a quick glance at a few examples, but did not get a clarification on this.  I am looking to have something close to a listbox control or the table to where I can update just one column of values to line a 1 time per second pace.  I'm looking to display our acquisition of data values in a table or a listbox control.  The single list box seemed to work well for that, but I couldn't use the row headers to list the names of channel beside the channel values.  I thought to link the values of cursor in two areas of list to do this, but did not find any info on it for the single list box.

    I have a few questions:

    (1) I have a 1 d table to where I want to use this data to constantly update the first column (with a multitude of lines) of a table.  I'm looking for the best route to not take too much time for treatment by doing this.

    What is the best way to update the individual rows of a table?   Invoke the node "Value of the cell value"... or is there another method?

    (2) why is that, after each iteration else, row values are deleted?

    Also, for adding additional channels originally arrray... it is better to use the 'Array' subset then the function "Construct the table" or function "Subset of the table" and "insert table"?

    See the attached example.

    Thank you.

    Jeff· Þ· Bohrer says:

    (2) why is that, after each iteration else, row values are deleted?

    Classic race condition.  dump the loop and node-p and just wire the 2D table on the terminal Board. !

    I don't see the race condition.  What I see is the table once the last element has been written for it all run the oil.  I saw looked it with point culminating performance on.

    But I agree entirely with writing to the Terminal.  It is a 1 d array, so you will need to use an array of generation and convert a 2D array in order so that he could write correctly.

  • What is the best way to store the RCS for an insert/update in this rec

    Oracle on Win 64 non-conteneur 12.1.0.2

    When a record in one table is inserted or updated, what would be the best way to store the RCS for this record in this folder.

    I thought of a line after trigger, but did not know if this trigger to store the current_scn would still fire that trigger again (recursive trigger).

    Someone at - he a good idea of what the best way is to do?  The devs don't want to store the pk and the SNA in yet another table...

    Yes, row_dependencies would be the best way to go.  But mgmt doesn't recreate all tables for this.

    3rd party applications retrieve data from tables (all data).  We are looking for a way for them to just pull what is new or updated updated since their last sweater.

    I suggest that you try again and give all OF THE REQUIREMENTS.

    You have rejected ANY answer given and he justified using 'hidden' on what knowledge management or the devs want or do not want to. Stop making us guess what are the requirements and constraints. If you want a real answer then tell us ALL the news.

    When a record in one table is inserted or updated, what would be the best way to store the RCS for this record in this folder.

    Solomon answered repeatedly. If you want to add a column to a table to store the then "best" SNA is to let the Oracle to do this for you automatically by using the DEPENDENCY LINE.

    As he says also re-create the table to add this clause will be MUCH MORE EFFECTIVE that everything THAT you can do it manually. It will be also more accurate because Oracle will fill the value ORA_ROWSCN with the SNA at the time the line was committed. You, as long as user, can't fill a column in function when a line is engaged since real VALIDATION belongs to a transaction, not the line or the trigger that you use.

    Yes - there are two drawbacks to this method:

    1. you need to re-create the table

    2. you cannot add an index to this "hidden" column

    The devs don't want to store the pk and the SNA in yet another table...

    Then? Who cares what the devs want to do? You want the BEST solution? Next, you will need to put aside personal preferences and determine what is the 'best' solution. Why it is important that certain dev wants to do this or not?

    OK, the problem of biz is now, 3rd party external users are an all-wheel drive large number of tables in the database via the API that we wrote.  That was obviously interrupted OLTP during the day.  To reduce to the minimum, we want for them just to extract data that has been inserted/updated since their last sweater.

    It is the definition of a "replica" DB Then why don't you consider a real replicated DB? You can use DataGuard and have replicated DB which is read only that can be used to generate reports. Oracle does ALL the work to keep ALL the tables in sync. You and your developers do NOTHING!

    We thought that store the RCS higher their last sweater would allow the API to extract only data with YVERT higher than their last data pull CHN.

    OK - except you keep rejecting solutions actually do. Ask you questions about the SNA stored in the same table, but then reject the solution that does this. And then you add your "devs" don't want to store the info in a new table either.

    Then your solutions must ONLY use the replication or Log Miner. The REDO logs have all changes, if you want to extract yourself. Replication (e.g., DataGuard) will use these logs for you to maintain a replicated database.

    We thought about it, but recreate all tables in production with ROWDEPENDENCIES as well as dealing with CF and other dependencies idea this was shot.

    Well you NEVER mentioned you "thought that" and rejected it. And you NEVER mentioned anything about FKs and other dependencies. What is FKs and other dependencies which prevents this working solution? Tell us! Give us ALL the information.

    Wouldn't a trigger AFTER LINE capture the commit YVERT?  Or is after really not after validation?

    No - a trigger has NOT one commit. A trigger runs as a step in a transaction. Validation applies to the entire transaction. Until you, or Oracle, issues a commit, there is NO "committed SNA" to be stored as ORA_ROWSCN.

    You can easily see that for yourself. Create a simple table with dependencies of the line and then update two different sessions.

    create the table emp_scn rowdependencies in select * from emp where rownum<>

    Select empno, emp_scn ora_rowscn

    Update emp_scn set work = 'b' where empno = 7499

    commit;

    The first SELECT statement will show you that each row has the same SNA.

    EMPNO, ORA_ROWSCN

    7369,70622201

    7499,70622201

    7521,70622201

    Now, do the update (but no commit), then SELECT it

    EMPNO, ORA_ROWSCN

    7369,70622201

    7499,

    7521,70622201

    Where is the value of 7499? This session will NOT see a value for the changed lines in the current transaction. Other sessions will still see the old value.

    Now do the validation, then SELECT

    EMPNO, ORA_ROWSCN

    7369,70622201

    7499,70622301

    7521,70622201

    7499 now has a new and different value than the other lines. It will not be this new value until the validation occurs.

    Yes, row_dependencies would be the best way to go.  But mgmt doesn't recreate all tables for this.

    Well, you got the answer you want. You ask the best way. Now, you say that you were told the best way. But now you don't like the answer.

    How is it our fault? Your question has been answered wasn't she?

    Here are the facts:

    1 oracle creates a history of changes - the REDO log files

    2. you can use Log Miner to extract these changes

    3. you can create your own change log by adding a log file of MV to your table.

    4. you can then write a custom code to use this MV log file to determine which rows to "reproduce".

    So far reject you all THE POSSIBLE solutions.

    Accept it or change the requirements to allow one of the solutions proposed to be used.

    Personally, if I HAD to use a customized solution, I would use a MV journal to record the ROWID of the lines that have changed (for tables ROWID cannot be changed). I would then extract the appropriate lines by pulling on the lines corresponding to these row ID.

    Even that has problems since a line can be changed several times and children lines can also be amended several times - these questions FK you mentioned.

    I suggest you read this entire thread on AskTom a dozen years ago. It addresses ALL these issues.

    https://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:16998677475837

    Then in your next reply on this topic give us a summary of where some things with your question and what help you further expect.

  • Best way to migrate the Apex in Production applications - how users are affected?


    Hello

    We have been migrating our apex in production applications after the opening hours to try to minimize the impact on users. Can the affected users if they use the application while migration is taken?

    It's how we migrate:

    -We export enforcement apex of the development environment. This creates a SQL file.

    -Then the SQL file is imported into the Production by using the option 'reuse application ID export file XX'

    Please let me know if there is a better way to move the application in production, and if the user isn't be affected if we during opening hours.

    Thank you

    Violeta

    Hi Violeta,

    Violeta wrote:

    We have been migrating our apex in production applications after the opening hours to try to minimize the impact on users. Can the affected users if they use the application while migration is taken?

    It's how we migrate:

    -We export enforcement apex of the development environment. This creates a SQL file.

    -Then the SQL file is imported into the Production by using the option 'reuse application ID export file XX'

    Please let me know if there is a better way to move the application in production, and if the user isn't be affected if we during opening hours.

    Yes for sure users will be get affected when you replace the current with a new app, if they use it at the same time.

    Another best way to move the application to the production (keeping the same URL of deployment) is to use the Application Alias for your URL of the App Production.

    In this way, you can import the application while users are using the old application. And then after opening hours all you have to do is delete the alias from the application of the old app and assign this alias to your new application.

    Refer to the following response: Re: versioning in Apex (the thread is on version control, but, in this reply, I have explained the deployment of Application Alias method).

    I hope this helps!

    Kind regards

    Kiran

  • Best way to discover the top N

    Hi all

    Sorry to ask a question on Friday. I've had this issue for some time now, what is the best way to discover the first N?

    For example, how do you know top 10 Web hosts that have the highest use of CPU for a certain period of time.

    One way to do is to create a WCF application that returns topN HostCPUs order to use/period/average. When the interval is small, like the last hour, it works, but if I increase the time range from 1 day, the request will expire after 60 seconds. We have 500 + guests on this FMS. Not only we want to watch the hot servers right now, but also want to watch the hot servers say yesterday, or last month.

    Another way is to use groovy code below, when I use retrieveLatestValue to get the current value, it's fast, but if I replace it with retrieveAggregate and make the time range for the previous 24 hours, it takes a few minutes to run.

    #! HostCPUs # .getTopologyObjects (extinguish) {a, b->

    go = server. DataService.retrieveLatestValue (a 'use'). value?. AVG

    If (goes == null)

    go = 0

    VB = server. DataService.retrieveLatestValue (b, 'use'). value?. AVG

    If (vb is nothing)

    VB = 0

    VA - vb > 0? 0: 1

    } .subList (0, 10)

    Then, of course, these are not very effective. Is there a better way to get this top N list I'm looking for?

    Thank you

    Xiaoning

    Here is an example of the batch api to query the memory of the virtual machine, and then I take action on a specific period of time.

    import com.quest.nitro.service.sl.interfaces.data.IDataService;

    import com.quest.nitro.service.sl.interfaces.data.ObservationQuery;

    import com.quest.nitro.model.topology.TopologyObject;

    import com.quest.nitro.service.sl.ServiceLocatorFactory;

    Import org.apache.log4j.Logger;

    def LOG = Logger.getLogger ("batch.query.test");

    topologyObjects = new HashSet (#!) VMWVirtualMachineMemory # .topologyObjects);

    Log.info ("topology objects querying ${topologyObjects.size ()}...");

    endTime = System.currentTimeMillis ();

    startTime = endTime - (4 * 60 * 60 * 1000 L);

    IDataService dataSvc is ServiceLocatorFactory.getLocator () .getDataService ();.

    Query ObservationQuery = dataSvc.createObservationQuery ();

    query.setStartTime (startTime);

    query.setEndTime (endTime);

    Query.include (topologyObjects, "active");

    Query.include (topologyObjects, "affected");

    Query.include (topologyObjects, "zero");

    result = dataSvc.performQuery (query);

    long term = System.currentTimeMillis () - endTime;

    Log.info ("request completed in ${duration} ms.");

  • The best way to change the red color to white?

    Can someone tell me the best way to change the red part of the label in this image for white? I'm having a hard time understand this point and I know there must be a solution simple or semi-facile. I have about 10 of these I need to change. Thanks for the help!

    label.jpg

    Hi Sheera730,

    Please take a look at the following article, it should be useful: https://blog.udemy.com/photoshop-replace-color/

    Kind regards

    Tanuj

  • Best way to limit the iOS devices?

    What is the best way to limit the compatibility of my AIR application so that users with the iPhone/iPod 1st-3rd generation cannot download it from the app store?

    I am about to submit my AIR application for Apple app store & have designed so that it works well on iPhone/iPod 4 + and all iPads. So, I would exclude users with older iPhones/iPods of the possibility to download it.

    I searched online and a number of people suggest adding a restriction based on requiring front facing camera.

    that is, adding the following line in the info.plist file:

    <key>UIRequiredDeviceCapabilities</key><string>front-facing-camera</string>

    But, I read the posts of some people who have tried this and it worked: he did not exclude iPhone 3GS. See the last post here.

    Can anyone confirm that it is a reliable method? I understand there is a small chance Apple will reject your application based on the fact that you add an unnecessary exclusion - that is my app requires in reality a front facing camera.

    Also, I noticed that another approach is to restrict the version of the OS. If you want to restrict the minimum version of the operating system of 6.2, which should exclude iPhone/iPod 1st-3rd generation like iPhone 3GS not going only up to OS 6.1.6 I think.

    So, the solution would be to add the following in the descriptor xml file:

    <key>MinimumOSVersion</key>
    <string>6.2</string>

    The 3GS is not compatible OS7 (OS6.1.6 I think is the last) then you can simply apply OS7.

    To do this, in your , you can specify as follows:

    MinimumOSVersion

    7.0


    Edit:


    Hey Yes, I see that you've done your homework. You can choose 6.2, but there is really no reason. iPad1 is locked in OS5 so you lose (very small part of the market) but the iPad2 and up supports OS7 and iPhone 3GS cut so 4 and below you really need to specify OS7 and up to. 6.2 would work as well. If you need support iPad1 so it is not ideal.

  • Need help: best way to exchange the Ipads?

    Dear all,

    Need help a genre:

    I use Ipad Air2 and my father is using retina Ipad Mini... I gifted him before 2 years...!

    We thought to share the Ipads because he loved the biggest... Can someone guide what is the best way to swap the parameters of the iPad?

    It is by taking backup and restore from Icloud? There will be data loss? or anything else that needs attention (something that he needed to be reconfigured)?

    Any help is very appreciated!

    Make a backup of each individual iPad. Use your own accounts: How to back up your device using iCloud or iTunes - Apple Support

    Import your photos from each iPad: import pictures and videos from your iPad, iPhone or iPod touch to your computer - Apple Support

    Then do it on every iPad: what to do before you sell or give away your iPhone, iPad or iPod touch - Apple Support

    Then restore the backup in your 'new' ipads: restore your device from an iCloud or iTunes backup - Apple Support

    If the ipads have the same size of storage with the same iOS version, it should work fine. -AJ

  • best way to clear the cache on an iMac 2011 - el capitan

    best way to clear the cache on an iMac 2011 - el capitan

    The best way is not for everyone. Clear the caches unnecessarily makes your computer run more slowly while they are rebuilt. Did you have a specific problem that you thought that clearing cache can solve? If so, post on the real problem.

Maybe you are looking for