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!

Running sql file in every schemas

greenyAug 27 2010 — edited Aug 27 2010
Version: 10.2.0.3

I have an sql script which i need to run on every schemas.
I found this OTN thread to be useful
4499919

The original working SQL from the above OTN thread:
SELECT A
FROM
(
SELECT   username, 'CONNECT ' || username || '/secret@clmdb' A
    FROM dba_users
   WHERE username LIKE 'TN%'
     UNION ALL
SELECT USERNAME, '@D:\Work\RunOnAllSchemas\change1.sql;'
    FROM dba_users
   WHERE username LIKE 'TN%'
     ORDER BY 1,2 
)
I don't understand why a simplified version(with DUAL) as shown below is not working. The query is ignoring the second query in UNION ALL
SELECT A
FROM
(
SELECT   username, 'CONNECT ' || username || '/secret@clmdb' A
    FROM dba_users
   WHERE username not in ('SYS','SYSTEM')
     UNION ALL
SELECT user as username, '@D:\Work\RunOnAllSchemas\change1.sql;' from dual
  
)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 24 2010
Added on Aug 27 2010
9 comments
882 views