Compare 45 columns and update one table col

I am using Oracle 9i database.I need to compare each record between two tables
and update the one of table column (what records are updated)
CURSOR cur1 is select t1., t2. from t1, t2 where t1.primarykey = t2.primarykey
FOR rec1 IN cur1
LOOP
IF rec1.t1_col_1<>rec1.t2_col_1
then
update t1
set col_t1.rem="MOdified",t.col_1=rec1.t2_col_1
where t1.primerykey=rec1.primarykey
END IF;
IF rec1.t1_col_2<>rec1.t2_col_2
then
update t1
set col_t1.rem="MOdified",t.col_2=rec1.t2_col_2
where t1.primerykey=rec1.primarykey
END IF;
..........45 if else conditions
END LOOP;
I have 1 million records to compare and 45 columns to compare, how do I increase performance.
Currently it takes about 5hrs for the cursor to go through this if -else comparison.
Thanks and Regards
Swayamprakash.Chiluveru

Hi Swayamprakash,
Few basics first.
1. DML SQL's perform better than PL/SQL. Sounds great but Oracle then need to hop between SQL and PL/SQL engine for every record in the cursor causing THRASHING. This is an old concept, reference of which can be found in Operating Systems.
With Bulk Collect option, this could be minimized to a large extent, but causes a large amount of Undo being generated. This is another pitfall of using Bulk Collect. Morever, when you expect more percentage of records to be updated, it is advisable that the indices (if any) must be disabled. They can be rebuild afterwards causing very minimal amount of Undo. Performance gain is expected here.
Now a query that you need to clarify:
1. One million records to be updated on a diurnal basis - An OLTP database might need this functionality which is better handled by a screen driven interface rather than a SQL/Procedure running in background.
An OLAP database must simply ignore such requirements for they are meant to be history archives.
Suggestion:
Merge - Seems to be the only optimal solution at the moment for the exact requirements are unclear. Already, somone has suggested this.
Oracle Developers, DBA's must setp out from technicalities and turn towards functionality.
Kind regards,
Abhijit

Similar Messages

  • Comparing Two tables with 300k records and update one table

    Could you let me know how to compare two tables having 300k records and update one table.below is the scenario.
    Table Tabl_1 has columns A,B and Tabl_2 has columns B,new_column.
    Column B has same data in both the tables.
    I need to update Tabl_2 in new_column with Tabl_1 A column data by comparing B column in both tables.
    I m trying to do using PLSQL Tables.
    Any suggestion?
    Thanks.

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    If you're asking about a DML statement, such as UPDATE, the CREATE TABLE and INSERT statements should re-create the tables as they are before the DML, and the results  will be the contents of the changed table(s) when everything is finished.
    Always say which version of Oracle you're using (for example, 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    ef2019c7-080c-4475-9cf4-2cf1b1057a41 wrote:
    Could you let me know how to compare two tables having 300k records and update one table.below is the scenario.
    Table Tabl_1 has columns A,B and Tabl_2 has columns B,new_column.
    Column B has same data in both the tables.
    I need to update Tabl_2 in new_column with Tabl_1 A column data by comparing B column in both tables.
    I m trying to do using PLSQL Tables.
    Any suggestion?
    Thanks.
    Why are you trying to use PL/SQL tables?  If tabl_1 and tabl_2 are regular database tables, it will be much simpler and faster just to use them.
    Depending on your requirements, you can do an UPDATE or MERGE, either in SQL or in PL/SQL.

  • Check two columns and update other table

    HI ,
    I have a table called trackCenterline .Below is the table.
    What i want to do is If the segmentSequenceID is 1 it should pick the corresponding SegmentID i.e 10001 and Check for the same segment id in other table called TrackSegment which is below.  and pick the BeginMilepost of that segmentID and Update That
    Milepost in a new table .At end SegmentSequenceID number it should pick ENDMilepost and update
    TrackCenterline table.
    TrackSegment table
    In the below table for 10001 SegmentID it should pick BeginMilepost. For end Number of SegmentSequenceID in above table ID ends at 121 for that end sequenceID It should refer TrackSegment table below and pick EndMilepost and should be updated in another
    table Milepost column.
    after that a new segment starts with new sequence .and so on ...
    bhavana

    Hi Deepa_Deepu,
    According to your description, since the issue regards T-SQL. I will help you move the question in the T-SQL forums at
    http://social.technet.microsoft.com/Forums/en-US/home?forum=transactsql. It is appropriate and more experts will assist you.
    When you want to check two columns from two tables then return some results and update the third table. I recommend you use join function and combine two tables, then use update select from statement for modifying the Mailpost table. You can refer to the
    following T-SQL Statement.
    -----using join to connect to two tables
    select TrackCenterline.FeatureId,TrackCenterline.SegmentId,
    TrackCenterline.SegmentSequenceId,TrackSegment.BeginMilepost,TrackSegment.EndMilepost
    from dbo.TrackCenterline join dbo.TrackSegment
    on TrackCenterline.SegmentId=TrackSegment.SegmentId
    order by TrackCenterline.SegmentId, TrackCenterline.SegmentSequenceId
    ---the result shows as following.
    FeatureId SegmentId SegmentSequenceId BeginMilepost EndMilepost
    AMK100011 10001 1 61.0000 61.3740
    AMK100012 10001 2 61.0000 61.3740
    AMK100013 10001 3 61.0000 61.3740
    AMK1000121 10001 121 61.0000 61.3740
    AMK100021 10002 1 61.1260 61.7240
    AMK100023 10002 3 61.1260 61.7240
    AMK100033 10003 3 61.3740 62.9530
    -----Then you can use update select from statement to modify the Mailpost table, Or you can post the table structure of Mailpost
    And for more information, you can review the following article about update statement.
    http://www.techonthenet.com/sql/update.php
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • How to update one table based on another table ??

    Hello Friends:
    I am trying to run the following query in oracle but it won't run.
    UPDATE BOYS
    SET
    BOYS.AGE = GIRLS.AGE
    FROM GIRLS
    WHERE
    BOYS.FIRSTNAME = GIRLS.FIRSTNAME AND
    BOYS.LASTNAME = GIRLS.LASTNAME;
    This query runs fine in sql server but in oracle its saying can't find "SET". PLease tell me what is the correct syntax in oracle to update one table based on another table.
    thanks

    See if this helps.
    If you wrote an SQL statement:
    update boys set age = 10;
    Every row in the boys table will get updated with an age of 10. But if you wrote:
    update boys set age = 10
    where firstname = 'Joe';
    Then only the rows where the firstname is Joe would be updated with an age of 10.
    Now replace the 10 in the above statements with (select g.age from girls g where g.firstname = b.firstname and g.lastname = b.lastname) and replace where firstname = 'Joe' in the second statement with where exists (select null from girls g where g.firstname = b.firstname and g.lastname = b.lastname). The same concepts apply whether 10 is an actual value or a query and whether you have a where clause with the update statement to limit rows being updated.
    About the select null question regarding the outer where clause:
    Since the query is checking to see if the row in the girls table exists in the boys table what the column is in this select statement doesn't matter, this column isn't being used anywhere. In this case Todd chose to use null. He could have also used a column name from the table or a lot of times you'll see the literal value 1 used here.

  • Analysing and Updating a table

    Hi,
    Can anyone help me on follwing query..
    Can analyse of a table and updation on to same table can happen paralley?
    thank in advance.

    What's your db version? The very first thing is that you should not use the analyze command but dbms_stats package. Now , I am not sure why you want to gather the stats and update the table at the same time? As mentioned by Erica, the update should be followed with the stats gathering. And about the index usage, there are couple of things that can stop index from being used, for example, low selectivity on the column can very well stop the index. Other than that, if you are accessing the column containing the index alone and the column is supposed to contain the null values, oracle would rather use a FTS than using the index which actually makes perfect sense since use of index would result in incorrect data. So there can be couple of htings possible which may stop your index from being used. All what dbms_stats(and even Analyze) command would do , is to make the distribution of the data known tooracle. Having stats alone doesn't guarantee that the index would be used for sure.
    HTH
    Aman....

  • Updating one table with mult. table where clause

    I'm having problems with my update statement. I want to update one table that has a mulitple table where clause. Not sure how to accomplish this. Here is what I have so far.
    update lawson.apvenmast a
    set vendor_status = 'I'
    where ((select * from apinvoice i
    where i.due_date <= TO_DATE('20011231', 'YYYYMMDD') and
    i.vendor = a.vendor)
    ((apvenmast.ven_class = 'INS') or
    (apvenmast.ven_class = 'REF')));
    Am I on the right track?
    thanks in advance for any help.
    Lisa Mears

    A lot is missing.
    where ((select * from apinvoice iA where clause should be like
    where <something> IN (select <something> from ...)
    ((apvenmast.ven_class = 'INS') or
    (apvenmast.ven_class = 'REF')));Where does this belong? There is no AND or OR with these two lines.
    Check your table aliases too.

  • Updating one table is updating ALL the materialized views

    We have a number of tables and also a number of materialized views that are interconnected. For some unexplained reason, when we update one table that should refresh one materialized view, all the materialized views are refreshed. It's causing massive bottlenecks on our system and we can't find the cause. Does anyone have any thoughts?

    "when we update one table that should refresh one materialized view, all the materialized views are refreshed" --If that table is used in the creation of all materialized views,then it will try to refresh all of them..(ON COMMIT REFRESH)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to call a idoc in abap program and updates catsdb table

    how to call a idoc in abap program and updates catsdb table
    thank you,
    Jagrut BharatKumar Shukla

    Hi Kishan,
    You can refer to following help document,
    http://help.sap.com/saphelp_nw04/helpdata/en/bf/d005244e9d1d4d92b2fe7935556b4c/content.htm
    Regards,
    Meera

  • TS3694 I try to update my iPhone 5 but in the middle of the way error 1603 didnot allow me I did every thing that I read about it but in every computer and updated one it is the same and now I am in DUF mood and my phone can not start what I must to do

    I try to update my iPhone 5 but in the middle of the way error 1603 didnot allow me I did every thing that I read about it but in every computer and updated one it is the same and now I am in DUF mood and my phone can not start what I must to do

    The program is for replacement since Apple does not repair iDevices...you take your non-working or damaged iPhone to an Apple store genius bar, or send to Apple service, and they provide a refurbished unit as a replacement, for a fee, of course.  You will have to talk with Apple to see if you get all components or just the iPhone replaced.
    With AppleCare+ you can have two out-of-warranty replacements for a cost of $49 each.

  • Comparing data size in one table to column widths in another table

    I have data in a table that has a large number of columns, many of them nvarchar of varying widths.  Im trying to take that data and insert it into another table but Im getting the warning message about string or binary data being truncated.  I
    suspect there is a field somewhere that is not large enough for the data.  However, I run across this often enough I would like to come up with a better solution than just eyeballing the data.
    I found this example
    http://www.sqlservercentral.com/Forums/Topic1115499-338-2.aspx
    (credit goes to poster in the linked thread above)
    Select columns
    into #T
    from MyDataSource;
    select *
    from tempdb.sys.columns as TempCols
    full outer join MyDb.sys.columns as RealCols
    on TempCols.name = RealCols.name
    and TempCols.object_id = Object_ID(N'tempdb..#T')
    and RealCols.object_id = Object_ID(N'MyDb.dbo.MyTable)
    where TempCols.name is null -- no match for real target name
    or RealCols.name is null -- no match for temp target name
    or RealCols.system_type_id != TempCols.system_type_id
    or RealCols.max_length < TempCols.max_length ;
    Why a full outer join ?  Why not just a left join, since I really only want to see the matches on my source table?
    When Im running this against the table im interested in, it doesnt seem to find matches between my target table and my temp table 

    As an outer join of any type, that query won't work well.  For example, suppose you do a left join.  So the query begins by getting every row from tempdb.sys.columns (whether it is in #T or not).  Consider a row for a column which is not in
    #T, you look for matches for rows in Mydb.sys.columns ON
    on TempCols.name = RealCols.name
    and TempCols.object_id = Object_ID(N'tempdb..#T')
    and RealCols.object_id = Object_ID(N'MyDb.dbo.MyTable)
    Notice that since the row you are considering is NOT a column in #T, the second part of the ON condition is not true, so the whole ON condition will not be true.  But this is a left join.  So the join keeps this row with NULL's in the columns coming
    from the RealCols table.  Then you do the where condition, but the connections are all OR and one of the conditions is RealCols.name is null (which it is because there was no match), your output will include a row for this column in tempdb even though
    this column is not in #T.  So if you use a left join, the output of this query will include a row for every column in every table in tempdb not named #T.
    Similarly, if you do a right join, you get a column for every row of every table in MyDb which is not a column in dbo.MyTable.
    And a full join (which you are doing above) will return a row for every column in every table in both tempdb and MyDb.
    This query will sort of work if you make it an inner join.  But even then it won't find every possible cause of string or binary truncation.  For example, you are doing RealCols.max_length < TempCols.max_length.  But in sys.columns, if
    you have a varchar(max) column, max_length is stored as -1.  So if a column in RealCols is varchar(50) and the same column in TempCols is varchar(max), that column will not show up as an exception, but of course, you can get truncation if you attempt
    to store a varchar(max) in a varchar(50).
    I would run a query more like
    Create Table FooX(a int, b varchar(20), c int, d varchar(20), e int, f varchar(20), g decimal(4,0));
    Select a, b, 1 as x, 'abc' as y, Cast('' as varchar(max)) As f, Cast(25.1 as decimal(3,1)) as g
    into #T
    from FooX;
    Select 'In Real, not in or different in Temp' As Description, name, column_id, system_type_id, max_length, precision, scale, collation_name From sys.columns Where object_id = Object_ID(N'FooX')
    Except Select 'In Real, not in or different in Temp' As Description, name, column_id, system_type_id, max_length, precision, scale, collation_name From tempdb.sys.columns Where object_id = Object_ID(N'tempdb..#T')
    Union All
    Select 'In Temp, not in or different in Real' As Description, name, column_id, system_type_id, max_length, precision, scale, collation_name From tempdb.sys.columns Where object_id = Object_ID(N'tempdb..#T')
    Except Select 'In Temp, not in or different in Real' As Description, name, column_id, system_type_id, max_length, precision, scale, collation_name From tempdb.sys.columns Where object_id = Object_ID(N'FooX')
    Order By name, Description;
    go
    Drop Table #T
    go
    Drop Table FooX
    The output of that is
    In Real, not in or different in Temp c 3 56 4 10 0 NULL
    In Real, not in or different in Temp d 4 167 20 0 0 SQL_Latin1_General_CP1_CI_AS
    In Real, not in or different in Temp e 5 56 4 10 0 NULL
    In Real, not in or different in Temp f 6 167 20 0 0 SQL_Latin1_General_CP1_CI_AS
    In Temp, not in or different in Real f 5 167 -1 0 0 SQL_Latin1_General_CP1_CI_AS
    In Real, not in or different in Temp g 7 106 5 4 0 NULL
    In Temp, not in or different in Real g 6 106 5 3 1 NULL
    In Temp, not in or different in Real x 3 56 4 10 0 NULL
    In Temp, not in or different in Real y 4 167 3 0 0 SQL_Latin1_General_CP1_CI_AS
    From which you can quickly see that the differences are c, d, and e are in the real table and not the temp table, f is in both tables but the max_length is different, g is in both table, but the precision and scale are different, and x and y are in the temp
    table, but not the real table.
    Tom

  • Dynamic Column Names from one table and its corresponding values from another table

    I have 2 tables. First tables gives the specification if a column is required or not. we have the 2nd table with the same column name where we provide the actual values.
    I want to select all the required columns from the 1st table and retrieve the values for those from the 2nd table. Both this i want to achieve in a single select statement.

    This wil require a dynamic Query with a Pivot
    DECLARE @ColsPivot as VARCHAR(MAX);
    DECLARE @Query  AS VARCHAR(MAX);
    1. Retreive the ID for all required field
    SET @ColsPivot = (SELECT STUFF((SELECT  ',' + quotename(CAST([RequirementID] as varchar(3))) FROM [dbo].[Requirement] WHERE required=1 FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)') ,1,1,''));
    This will give you : [1],[2],[3],[8],[9],[14] for exemple.
    2. Build your Query
    SET @Query ='SELECT ClientID,'+@ColsPivot+''
        FROM (
            SELECT [ClientID],[RequirementID],[Value]
            FROM dbo.RequirementValue
            WHERE ClientID=@CliendID --Optional SP parameter
        )src
              PIVOT(
                MAX(Value)
                for [RequirementID] in ('+@ColsPivot+')
        ) p';
    3. Exec(@Query);

  • Delta Calculation and Updating multiple tables

    We pull data from a System of Records table that contains the most up to date information. The information changes daily so we have a delta process to identify what new records were added, which records were deleted (records that are not found in the table as compared to yesterday) and which were updated. Delta process compares the already loaded data with the newly updated SOR data to find the differences.
    Once the delta is established, either new records get added or existing records get updated or existing records are marked as inactive (Deletes). Additions and Updates generally happen across multiple destination tables.
    Updates are identified by looking at different columns to see if any one column is changed. These columns end up in different tables.
    Example
    Source Delta Table, S1
    ID COL1 COL2 COL3 ACTION
    1 abc xyz pqr A
    2 bcd lmn def U
    S1.Col1 maps to Destination Table D1.Col23
    S1.Col2 maps to Destination Table D2.Col45
    S1.Col3 maps to Destination Table D3.Col11
    Currently all tables are updated irrespective of whether the relevant data has changed or not (All 3 destination tables are updated).
    I would like to know which of the Columns for a given row has changed values so that I can update only the relevant tables.
    Thus if additional columns are available that act as flags
    Source Delta Table, S1
    ID COL1 COL2 COL3 ACTION COL1 COL2 COL3
    1 abc xyz pqr A - - -
    2 bcd lmn def U N Y N
    3 kjh qwe iop U Y Y N
    then for incoming ID=2, I just have to update Destination Table D2 and not D1 and D3
    for incoming ID= 3, I have to update Destination Tables D1 and D2 but not D3.
    How can I achieve that?
    This is mainly to improve performance as the processing time is very short - Faster the delta processing, better will it be.
    Thanks in advance.

    Thanks for your response.
    My question was more towards establishing what has changed.
    Given a table, which is updated daily, how does one efficiently establish which data has changed?
    Here is an example to clarify my question further
    The Source table has the following data on a particular day
    Data in Source table on Monday               
    ID     Col1     Col2     Col3
    1     abc     bcd     cde
    2     def     efg     fgh
    3     ghi     hij     ijk
    4     jkl     klm     lmn
    Copy of the above data is stored in a Old Data table
    Data in Source table on Tuesday               
    ID     Col1     Col2     Col3
    1     bac     bcd     cde
    2     def     gfe     fgh
    3     ghi     jih     jik
    5     mno     nop     opq
    Data in Source Table is compared with data in Old Data Table
    Delta established by comparing Source Table with Old Data Table                    
    ID     Col1     Col2     Col3     Delta_Flag
    1     bac     bcd     cde     U
    2     def     gfe     fgh     U
    4                    D
    5     mno     nop     opq     A
    Rows with IDs 1 & 2 were updated - thus to be updated
    Row with ID 3 - no change so not seen in delta
    Row with ID 4 was not found - thus to be deleted
    Row with ID 5 was new - To be added
    I can do the above easily. I would like to a step further to be able to say for updates
    Row with ID 1 has Col1 changed
    Row with ID 2 has Col2 and Col3 changed
    Is there an easy way to do this?

  • Trigger and Update Flag Table

    I've recently started trying to automate around a dozen procedures. These procedures are set to run immediately after the necessary previous procedure(s) is(are) done.
    What I am attempting to accomplish is a single generic trigger that will fire off each procedure when its parent procedures have finished firing. This will be accompanied by an update_flag table with three columns
    PARENT_PRC----------------------CHILD_PRC----------------------FLAG
    parent_prc_name1--------------child_prc_name1-----------------N
    parent_prc_name1--------------child_prc_name2-----------------N
    parent_prc_name3--------------child_prc_name3-----------------Y
    Logic:
    *1.*     When a procedure fires it updates this table to set any rows in which it is the “PARENT_PRC” by updating the FLAG column to = Y.
    *2.*     The trigger will execute a child procedure if its flag (or in the case of multiple parent procedures; all of its flags) are set to 'Y'. This trigger is set to fire AFTER a table update on the UPDATE_FLAG table.
    ----a.     I have to execute the procedure UFLAG in a job because I want the trigger to execute the procedure and then continue running immediately, rather than wait for the procedure to finish then commit. This way the trigger could start several procedures all running at the same time.
    ----b.     I have made it an autonomous transaction because I needed the job to fire immediately rather than be queued, which required a commit within the trigger.
    *3.*     The last step is to set the flag in UPDATE_FLAGS back to 'N' for CHILD_PRC = '||uflag||' once the child procedure is complete.
    ----a.     I have tried placing the update child_prc = 'N' in the trigger but it won’t allow a trigger that fires on update to update the same table.
    ----b.     I want to avoid putting the update statement in all of my procedures because I would like the option of running these procedures manually for testing purposes WITHOUT effecting the update_flags table.
    Number 3. is the key problem I have been having. Placing code within the trigger to update the update_flags table setting 'Y's back to 'N's once the procedures have fired causes a deadlock error.
    I believe this is simply because the trigger is attempting to update a table which (upon updating) causes the same trigger to fire before it has finish executing.
    How can I update the Flag table to reset the update flags back to 'N'?
    Is there a different way of doing this all together?
    Here is some code with dummy procedures that demonstrates what I have so far.
    With this code, executing parent procedures should set the update_flag table to 'Y' for FLAG where procedure = 'parent_prc'.
    I need to find a way to execute the child procedures AND set the FLAG column back to 'N' from the trigger.
    ex. executing parent_1 should set update_flags.flag = 'Y' where parent_prc = 'parent_1' and thus execute procedure CHILD_A and CHILD_B.
    create table update_flags (parent_prc varchar2(10), child_prc varchar2(10), flag varchar2(1));
    insert into update_flags values('parent_1', 'child_a', 'N');
    insert into update_flags values('parent_1', 'child_b', 'N');
    insert into update_flags values('parent_2', 'child_c', 'N');
    insert into update_flags values('parent_3', 'child_c', 'N');
    insert into update_flags values('parent_4', 'child_d', 'N');
    CREATE OR REPLACE procedure parent_1 as
    BEGIN
    update update_flags set flag = 'Y' where parent_prc = 'parent_1';
    END parent_1;
    CREATE OR REPLACE procedure parent_2 as
    BEGIN
    update update_flags set flag = 'Y' where parent_prc = 'parent_2';
    END parent_2;
    CREATE OR REPLACE procedure parent_3 as
    BEGIN
    update update_flags set flag = 'Y' where parent_prc = 'parent_3';
    END parent_3;
    CREATE OR REPLACE procedure parent_4 as
    BEGIN
    update update_flags set flag = 'Y' where parent_prc = 'parent_4';
    END parent_4;
    CREATE OR REPLACE procedure child_a as
    BEGIN
    dbms_output.PUT_LINE('CHILD_A Worked');
    commit;
    END child_a;
    CREATE OR REPLACE procedure child_b as
    BEGIN
    dbms_output.PUT_LINE('CHILD_B Worked');
    commit;
    END child_b;
    CREATE OR REPLACE procedure child_c as
    BEGIN
    dbms_output.PUT_LINE('CHILD_C Worked');
    commit;
    END child_c;
    CREATE OR REPLACE procedure child_d as
    BEGIN
    dbms_output.PUT_LINE('CHILD_D Worked');
    commit;
    END child_d;
    CREATE OR REPLACE TRIGGER MASTER_TRG
    AFTER UPDATE
    ON UPDATE_FLAGS
    DECLARE
    Pragma  AUTONOMOUS_TRANSACTION;
    BEGIN
      DECLARE
      job_num number;
      uflag varchar2(1000);
      BEGIN
            select  MAX(case when COUNT(case when flag='Y' then 1 end)=COUNT(*) then CHILD_PRC else '  ' end)
            into uflag
            from        update_flags
            group by    child_prc;
            IF   uflag <> '  ' THEN
                                      --update update_flags set  flag = 'N' where child_prc = uflag     --(line of code that causes deadlock error)
                            dbms_job.submit (job => job_num,
                            what => ' '||uflag||';'
            END IF; 
       END;            
    COMMIT;
    END MASTER_TRG;
    execute parent_2;
    execute parent_3;

    >
    I think I am getting my head around the transactional/trigger issue.
    >
    It doesn't sound like it since you are still talking 'triggers'. At any rate it is OP that needs to get their head around it.
    OP doesn't even know what the entire process needs to be but has already decided that
    1. a single generic trigger that will fire off each procedure when its parent procedures have finished firing
    2. an update_flag table with three columns: PARENT_PRC, CHILD_PRC, FLAG
    3. a procedure fires it updates this table to set any rows in which it is the “PARENT_PRC” by updating the FLAG column to = Y.
    4. a job - I have to execute the procedure UFLAG in a job
    5. I have made it an autonomous transaction because I needed the job to fire immediately rather than be queued, which required a commit within the trigger.
    6. there should be an option of running these procedures manually for testing purposes WITHOUT effecting the update_flags table.
    Fortunately OP had the wisdom to ask
    >
    Is there a different way of doing this all together?
    >
    Doesn't anyone design things anymore? Seems like everyone just wants to decide what the solution ought to be be and then try to force the problem to fit into it.
    The first stage is the DESIGN - not the implementation details or technology to use.
    The first design step is to outline, or flowchart, the PROCESS that needs to take place. Since OPs post lacks sufficient detail I will substitute my own 'guesstimations' to illustrate.
    1. there are one or more 'parent' processes
    2a. these parent processes are allowed to run in parallel as they do not interfere in any way with the processing done by other parent or child processes. (is this true?)
    2b. these parent processes ARE NOT allowed to run in parallel as they may interfere with each other.
    3. Each parent process can have one or more 'child' processes. (it appears that these aren't really children but rather processes that are 'dependent' on the parent or that must always be executed after, and each time that the parent executes.
    So here are just SOME of the things that are missing that must be known before possible alternatives can be explored
    1. Re item #2 - can the parent processes be executed in parallel? Or must they be executed serially? Will any of the parent processes be dependent on any other parent or child process?
    2. What is the relationship between a parent process and its child processes? Is the parent always executed first? What triggers the parent execution? How often is it executed?
    What if it is already executing? What if other parent processes are currently executing? What if one or more of its child processes are executing? What if the parent process fails for any reason - what action should be taken?
    Based on what was posted a set of parent and child processes might need nothing more than: execute parent, execute child1, execute child2, . . ., execute childn.
    3. What is the relationship between the child processes that belong to the same parent? Can they be executed in parallel (i.e. are they completely independent)? Or must they be executed in some particular order? What if one or more of the child processes fails for any reason - what action should be taken?
    4. Will any other user or process be executing these parent or child processes? That could interfered with the automated stream.
    5. What type of exception handling and recovery needs to be implemented in one or more steps of the processing fail for some reason?
    Typically there is often one or more control tables (OPs flag table) to control and limit the processing. But the table would have status information for every process not just the children:
    A. STATUS - DISABLED, ACTIVE, RUNNING, IDLE, ERROR
    B. START_TIME
    C. END_TIME
    D. RESULT_CODE
    The control table can be used by a parent or child process to determine if it is permitted to run. For example the first thing a procedure might do is check it's own STATUS. If it is already running it would exit or log an error or message. If that test is passed it might check the status of any dependent processes. For example it might check that its child processes are ACTIVE and ready to run; if a child was still running the parent would exit or log an error or message.
    The control process would lock the appropriate control table records (FOR UPDATE) and would set the status and other fields appropriately to prevent interference by other processes or procedures.
    Design first. Then look at the implementation options.

  • Update One Table with three Apply Processes

    Hi.
    I have One Database Target with three APPLY processes updating a same table. Each APPLY process refer to a Source Capture remote process.
    But I am verifying there is no update in the table when change data on Sources Databases. This table has a PK with two columns.
    Someone has idea about this problem, and how to resolve it?
    Thanks very much.
    JoseFormiga

    Hi.
    See my definitions below with one table. I have a lot of tables with similar definitons:
    SOURCE: (BD1)
    =======
    begin
    dbms_streams_adm.add_table_rules (table_name => 'TSINMETRO.HW_COBRANCAS',
    streams_type => 'capture',
    streams_name => 'CAPTUPSIE_CAPTURE',
    queue_name => 'STRMADMIN.CAPTUPSIE_QUEUE',
    include_dml => true,
    include_ddl => true,
    inclusion_rule => true);
    end;
    begin
    dbms_streams_adm.add_table_propagation_rules (table_name => 'TSINMETRO.HW_COBRANCAS',
    streams_name => 'DE_MG_PARA_PSCI',
    source_queue_name => 'STRMADMIN.CAPTUPSIE_QUEUE',
    destination_queue_name => 'STRMADMIN.APPLYMG_QUEUE@psci',
    include_dml => true,
    include_ddl => true,
    source_database => 'ipemmg',
    inclusion_rule => true);
    end;
    declare
    source_scn number;
    begin
    source_scn := dbms_flashback.get_system_change_number();
    dbms_apply_adm.set_table_instantiation_scn@psci (source_object_name => 'TSINMETRO.HW_COBRANCAS'     ,
    source_database_name => 'ipemmg',
    instantiation_scn => source_scn);
    end;
    begin DBMS_STREAMS_ADM.ADD_COLUMN(rule_name=>'HW_COBRANCAS595',table_name=> 'TSINMETRO.HW_COBRANCAS'
    ,column_name=>'SRV_UNF_ID',column_value =>ANYDATA.ConvertNumber(35),value_type=>'NEW',step_number=>1,operation=>'ADD'); END;
    begin DBMS_STREAMS_ADM.ADD_COLUMN(rule_name=>'HW_COBRANCAS595',table_name=> 'TSINMETRO.HW_COBRANCAS'
    ,column_name=>'SRV_UNF_ID',column_value =>ANYDATA.ConvertNumber(35),value_type=>'OLD',step_number=>2,operation=>'ADD'); END;
    Target:
    =======
    begin
    dbms_streams_adm.add_table_rules (table_name => 'tsinmetro.HW_COBRANCAS',
    streams_type => 'apply',
    streams_name => 'applymg_apply',
    queue_name => 'strmadmin.applymg_queue',
    include_dml => true,
    include_ddl => true,
    source_database => 'ipemmg',
    inclusion_rule => true);
    end;
    I have more two Source DBs doing so.
    Thanks.
    JoseFormiga

  • How to avoid deadlock when multithreading updates one table same time?

    Multithreading calls the stored procedure at the same time to update data in one table. For a instance,
    Table1
    Col1 Col2 Col3
    C1 1 1
    C1 2 2
    C1 3 3
    C2 1 1
    Table2
    Col1 Col2 Col3
    C1 1 10
    C1 2 4
    C1 3 3
    C2 1 1
    There are several steps I want:
    1. Get the data in Table1 where Col1 = C1 in a cursor which has Col1 column and Col2 column.
    2. Cycle them one by one, and get the Col3 data from Table2 where Col1 = C1 and Table2.Col2 = Table1.Col2. (Due to deadlock is my concern, we use temp table, definityly it is not a good way. :( )
    3. Update Table1 Set Col3 = Table2.Col3.
    My new idea is when I get the collection from Table1 which Col1 = C1, I use this way below.
    First I set transaction in below way.
    SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
    Then
    select * from Table1 where Col1 = C1 for update nowait;
    In my opinion, if one thread lock the data for update, other thread won't select out that locked data. Does it work?
    Thank you.
    Best regards,
    Andreas

    Why is the data submitted as a collection in the first place?
    A collection is great as a program data structure - dealing with program variables. It is a very poor choice to use it to deal with Oracle data in a CRUD fashion.
    The purpose, ito dealing with Oracle data, of a PL/SQL collection is for one thing and one thing only - context switching.
    To reduce the number of times you need to step out of PL/SQL and into the SQL engine in order to pass data from one to the other. A collection allows you a bigger buffer area and thus less context switches.
    And that's it.
    A client (Java, C#, etc) that submits data to Oracle to be CRUD via a collection is a design flaw. A collection resides in "expensive" dedicated, non-sharable and non-scalable server memory.
    In order to CRUD a collection, you either need to write bare bones feature methods yourself, or cast that collection into a SQL structure and use more powerful and flexible and feature rich SQL against it.
    Which then begs the question - why did the client not submit that data directly to the SQL engine, either into a permanent table or a temporary table?
    Performance and scalability are issues that need to be addressed at core design level. It is not something that can be tacked on and "fixed" after the fact. So you need to make very sure that your reasons for not wanting to use a temp table (for example), are valid and sound technical reasons.

Maybe you are looking for

  • IPhone 5s battery life issues

    hi guys I feel like there is a problem with my iphone 5s. the battery life is really bad compared to my last iphone 5. I used to be able to charge my phone at the end of the day and would till have 40% or 50% left. now with this new iphone, it reache

  • Cannot Install Itunes on Windows 8.1 Pro

    I am trying to install ITunes x64 on windows 8.1 Pro and I keep getting an error message half way through saying "An error occurred during the installation of assembly  'Microsoft VC80 CRT type="Win32" . version="8.0.50727. 6195" ,publicKey Token="1f

  • How do you know when is it time for a new battery??

    my ipod is not being found by windows last night i went to bed and wake up in the morning and it doesn't work right now my ipod is showing three icons in rotation: -battery with lightning bolt but battery meter isn't moving -ipod with sad face -apple

  • Broadcast a live musical performance through Apple TV through my home theatre system

    I have small concerts in my living room regularly involving a piano, voice and wind instruments.  I'd like to use Apple TV to pipe this live music to other rooms in my house.  Is there a way to broadcast a microphobe wirelessly to my Mac and then thr

  • Value intervals for PO release

    Hi Can we put value intervals for the characterestic in the PO release classsification? Regards