Updating one table from another table

Rated 4.58/5 based on 720 customer reviews

This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. By joining today you can post your own programming questions, respond to other developers questions, and eliminate the ads that are displayed to guests. I'm having a problem updating one table with data from another in Access 2003.My database uses a form to add, edit and delete records from a table called Products.I have referential integrity set up between the tables with cascading updates and deletions.When a new product is added by the form, the Products table is updated with the Product Name and an autogenerated Product ID.The second table, Aliases, is made up of three fields, Alias ID, Product ID and Product Alias.Alias ID is the primary key and is also autonumbered.From this, update table COFP with information from COSP with value type 62 and same period.

This database was cobbled together over a number of years, and it started off serving a totally different purpose than it serves now. [web page table]page_id (autonumber)page_topic (text)... [topics table]topic_id (autonumber)topic_name (text)... Right now, the tables are joined by the two text columns (page_topic = topic_name) which is not ideal.

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 b.id=and 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.

Using cursor is ok, but it brings with a un-toleratable speed when operating on a large table. end loop End; It's working but taking a huge time/sometimes hang the computer. [email protected] update ( select upd.purchase_no u_pno, upd.amount u_a, 2 temp.purchase_no t_pno, temp.amount t_a 3 from upd, temp 4 where upd.urefitem = temp.urefitem ) 5 set u_pno = t_pno, u_a = t_a 6 / 635 rows updated. Is this time, 10 minutes for 12000 rows tables an acceptable (expected) time? Thanks Anandhi = b.cycle and b.site_id=44 and b.rel_cd in('code1','code2','code3') and b.groupid='123' 12,000 times?

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

Hi, Please go through the case I am mentioning below and if possible try to provide with a solution.

Leave a Reply