Load Oracle tables and switch public synonym

I need some help from Oracle and UNIX expertise point of view.

I have two tables, METADATA_A and METADATA_B. I need to switch loading these tables. If we load METADATA_A today, the following
week we would have to load METADATA_B.

There is a public synonym "METADATA" that sits on top of these two tables.

1) Find out which table is in use right now..

SELECT * 
FROM ALL_SYNONYMS 
WHERE SYNONYM_NAME = "METADATA"

2) Truncate opposite table

3) Load opposite table

4) Validate by doing a count * on the table to check the rows loaded.

5) Finally, switch synonym

Can this be achieved using shell script? Please advice.

Yes. I used to write perl scripts that would call Oracle SQL scripts. The perl script would be used to authenticate you to the database and then you would execute the SQL script from within your PERL script. It's been about 4 years since I've done it but it can be done.

-X

Thank you X....

If anybody has encountered this situation, please help me with a sample shell script...

Put me in the track and I will work on it...