Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PL SQL Example Help - Loop through tables and columns?

792833Aug 20 2010 — edited Aug 24 2010
Hi Guys, hoping somone could give me a PL SQL example to solve the problem below:

TABLE 1 NAME = CHEESE
COLUMNS = BLUE, SWISS, RED

TABLE 2 NAME = JUICE
COLUMNS = APPLE, PEAR, GRAPE

TABLE 3 NAME = BISCUIT
COLUMNS = CRACKER, CHOCOLATE


UPDATE [TABLE 1]
SET [1st COLUMN SPECIFIED FOR TABLE 1] = REPLACE([1st COLUMN SPECIFIED FOR TABLE 1], 'abc', 'xxx')
WHERE [1st COLUMN SPECIFIED FOR TABLE 1] LIKE '%abc'
OR [1st COLUMN SPECIFIED FOR TABLE 1] LIKE 'abc%'
SET [1st COLUMN SPECIFIED FOR TABLE 1] = REPLACE([1st COLUMN SPECIFIED FOR TABLE 1], 'ABC', 'YYY')
WHERE [1st COLUMN SPECIFIED FOR TABLE 1] LIKE '%ABC'
OR [1st COLUMN SPECIFIED FOR TABLE 1] LIKE 'ABC%'

(Repeat for TABLE 2)
(Repeat for 1st COLUMN SPECIFIED for TABLE 2)

(Go on to TABLE 3)
(Repeat etc)

Could somone show me the simplest way to achieve this in PL SQL?

Cheers!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 21 2010
Added on Aug 20 2010
8 comments
1,934 views