If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > update multiple tables at the same time

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-15-03, 05:38
klada klada is offline
Registered User
 
Join Date: Oct 2003
Posts: 3
update multiple tables at the same time

Hi!

I'm trying to update multiple tables at the same time. I have plenty of tables in the database which all have some columns in common, one of this tables i would like to change.

I tried something like this (which doesn't work - and a lots of variations which also don't work, but I think helps to understand the problem)

UPDATE
(SELECT table_name FROM user_tables WHERE table_name like 'TD%')
SET my_flag= 1 WHERE depNo=1

Is there any way to solve this problem with SQL (PL/SQL)?

Any help will be appreciated greatly. Thanks.

Klaus
Reply With Quote
  #2 (permalink)  
Old 10-15-03, 14:48
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Lightbulb

Have you tried dynamic SQL?

Code:

Begin
 For T In (Select Table_Name From User_Tables
            Where Table_Name Like 'TD%')
 Loop
   Execute Immediate 'Update '||T.Table_Name
                   ||'   Set My_Flag= 1 Where Depno=1';
 End Loop;
End;
/
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On