- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sql update QUESTIONS
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-16-2004 06:50 AM
тАО06-16-2004 06:50 AM
sql update QUESTIONS
I HAD TRIED THIS:
update uid_info set routing_id = (select a.routing_id from routing a , uid_info b where a.PART_NUMBER = b.PART_NUMBER
and a.DEFAULT_ROUTING='1')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-16-2004 06:55 AM
тАО06-16-2004 06:55 AM
Re: sql update QUESTIONS
set routing_id = (
select a.routing_id
from routing a
where a.PART_NUMBER = b.PART_NUMBER
and a.DEFAULT_ROUTING='1');
regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-16-2004 01:33 PM
тАО06-16-2004 01:33 PM
Re: sql update QUESTIONS
Fred has a good start, however you need to put a where clause on the update as well. I don't know enough about what you are trying to do, however this is an example of what I mean:
update users a set number =
(select number from phonelist b where a.username = b.username)
where exists
(select 1 from phonelistb where a.username = b.username);
Otherwise, you will repeatedly update the routing_id from the routing table for each row of the uid_info table.
Thanks,
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-16-2004 04:47 PM
тАО06-16-2004 04:47 PM
Re: sql update QUESTIONS
an alternative example using PL/SQL will be:
begin
for c1 in (select routing_id, uid_info from routing) loop
update uid_info
set routing_id = c1.routing_id,
uid_info = c1.uid_info;
where part_number= c1.part_number
and default_routing='1';
--dbms_output.put_line('updating '||c1.part_number);
end loop;
commit;
end;
hope this helps too!
(Note that doing it in a single SQL statement will be the best option, especially if the table has thousands of records)
regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-16-2004 04:47 PM
тАО06-16-2004 04:47 PM
Re: sql update QUESTIONS
an alternative example using PL/SQL will be:
begin
for c1 in (select routing_id, uid_info from routing) loop
update uid_info
set routing_id = c1.routing_id,
uid_info = c1.uid_info
where part_number= c1.part_number
and default_routing='1';
--dbms_output.put_line('updating '||c1.part_number);
end loop;
commit;
end;
hope this helps too!
(Note that doing it in a single SQL statement will be the best option, especially if the table has thousands of records)
regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-16-2004 05:25 PM
тАО06-16-2004 05:25 PM
Re: sql update QUESTIONS
MERGE INTO SALES_FACT D
USING SALES_JUL01 S
ON (D.TIME_ID = S.TIME_ID
AND D.STORE_ID = S.STORE_ID
AND D.REGION_ID = S.REGION_ID)
WHEN MATCHED THEN
UPDATE
SET d_parts = d_parts + s_parts,
d_sales_amt = d_sales_amt + s_sales_amt,
d_tax_amt = d_tax_amt + s_tax_amt,
d_discount = d_discount + s_discount
WHEN NOT MATCHED THEN
INSERT (D.TIME_ID ,D.STORE_ID ,D.REGION_ID,
D.PARTS ,D.SALES_AMT ,D.TAX_AMT ,D.DISCOUNT)
VALUES (
S.TIME_ID ,S.STORE_ID ,S.REGION_ID,
S.PARTS ,S.SALES_AMT ,S.TAX_AMT ,S.DISCOUNT);
sks