There are one column in each table, call id, to link them. --For incremental/New data----- insert into A select * from B where column_name NOT IN (select column_name from B); --For Edited Data------- cursore C_AB select * from B minus select * from A For R in C_AB loop Update A set....where ... this shows how I would approach getting the first two columns -- just add the other 2 and use merge to keep filling temp -- and then update the join: [email protected] -1 5 group by urefitem ) b 6 on (temp.urefitem = b.urefitem) 7 when matched then update set amount = b.sum_total 8 when not matched then insert (urefitem,amount) values ( b.urefitem, b.sum_total) 9 / 398 rows merged. using a cursor means you are back to "slow=very_true" you already WERE updating on a bulk basis??? But when I run the following query, it takes up 50% of CPU. tab A has these columns: id, cycle, pop tab B has these columns: id, cycle, site_id,rel_cd,groupid update tab A a set pop= (select count(*) from tab B b where a.cycle = b.cycle and b.site_id=44 and b.rel_cd in('code1','code2','code3') and b.groupid='123') where pop is null and id in(select id from tab B); call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 2 496.35 499.54 7530955 9902630 76532 11444 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 3 496.35 499.54 7530955 9902630 76532 11444 Misses in library cache during parse: 0 Optimizer goal: CHOOSE Parsing user id: 305 Rows Row Source Operation ------- --------------------------------------------------- 1 UPDATE tab A 11445 MERGE JOIN 5942 VIEW VW_NSO_1 5942 SORT UNIQUE 31227 TABLE ACCESS FULL tab B 17385 SORT JOIN 12601 TABLE ACCESS FULL tab A Now my questions are: 1. We have several such updates that creates the same problems on the server from time to time and I would appreciate some guidance to resolve this.

You could create a trigger on table B that updates table A every time field_2 on table B is updated.

I have two tables in different databases on the same database server.

Even the idea create a temporary table holding only primary key and Column b, and then apply cursor to it is slow. Would u please help me how can i faster my procedure.u have given information 9i it same for oracle8i & dev6i.please help me Thank u very much for ur kind update information is really nice and working very insert----same prolem. That means -- just using math here -- that we have 600 seconds, 12,000 queries to run, 12000/60 = 20, so we are doing 20 per second -- or each query is taking 0.05 cpu seconds to run. do anything 12,000 times and you might have a problem tho! this might be one of the rare times that a temp table can be useful.

I am think of the way without using cursor, script as below. I don't understand what's the problem.i am going to give u full overview of my problem. The software is available in different portion of the country for data entry and report generation etc. What about: create global temporary table gtt ( id int primary key, cnt int ) on commit delete rows / you'll add that ONCE, it'll become part of your schema forever....

It will need the primary key constraint on B though, if you do not have one BUT is unique, you can: [email protected] I can think of another instance (at least with v8.1.5) where the second example (updating the table via a subquery) works better than the first example (updating the joined tables). My last PL/SQL code was just a test as i was interested more in the performance during update, so i missed the commit point. REGISTRATION where vistemp.registration.bin=vis.registration.bin) /am i right? Whenever anyuser insert/update anything,system date is inserted with them and i am exporting that data by using that system date."AM I IN RIGHT WAY? Another table summary of orders tt1 which is having current year summation and respective previous year summation columns. Type ------------------------------- -------- ------------ ORDER_NUMBER NUMBER(10) ORDER_DATE DATE CY_ORD_AMT NUMBER PY_ORD_AMT NUMBER Order date is current year date.

If the user has update permission on table A, but only has select permission on table B, they cannot update via the first example. I tried the MERGE command and it is 10 fold fast, however i have few questions. " c)if i have a composite key then "---where a.key1=b.key1 and a.key2=b.key2 and----) am i right for both insert/update by given ur advice? I am getting current year data first into above table after I am trying to update previous year amount.

That information, along with your comments, will be governed by DISQUS’ privacy policy.

By commenting, you are accepting the DISQUS terms of service.

Given that, we can: [email protected] select * from a 2 / ID A1 ---------- ------------------------- 1 Hello 2 World The following updates are equivalent as well - they do the same thing differently. REGISTRATION); RUN and Computer in BIG Busy mood(Hang). REGISTRATION(BIN, NAME, NAME_ALIAS, COR_GROUP, AUTHOBY, AUTHODATE, CG_NAME, ADD1, ADD2, ADD3, TEL1, FAX1, ADD5, ADD6, ADD7, TEL2, FAX2, ADD9, ADD10, ADD11, TEL3, FAX3, TP_TYPE, TRD_LINC, TRD_FY, TRD_AUTH, IMP_REG, EXP_REG, REG_TYPE, TIN, STATUS, PRE_BIN, DATREG, STAT_CHNG, ACT_CODE, ACT_MULT, ITEM_TYPE, OLD_ACT, APP_CAT, LCODE, ISSUE_DATE, VREG, M_POSI, MFUNC, SFUNC, LAST_USER, LAST_ACCS, TREG, PAY_FREQ, CREG, EREG, OREG, OP_BAL, OP_BAL_DT)select BIN, NAME, NAME_ALIAS,---- from VIS. In update portion i am facing another problem by ur recomended code. INSERT into abc values (RTRIM(col1), RTRIM(col2) .) There is another option where I can use SELECT RTRIM(col1), RTRIM(col2) from xxx where RTRIM(col1) = ‘yyy’ and then directly use insert into target table without RTRIM.