I have table ‘stf_table’ under the schema ‘staff’ with username ‘staff’.
I have table ’emp_table’ under the schema ’employee’ with username ’employee’.
Both of these are under the same database SID/host/port but user ‘staff’ doesn’t have privelege to query tables under schema ’employee’ and vice versa (ie. user ’employee’ doesn’t have privelege to query tables under schema ‘staff’). But each user can query the table under their own schema. Note: I cannot grant extra privileges and I don’t want to have to dump both tables into a local schema.
Is it possible to write a PL/SQL proc or package that would do the following?
select count(*) from stf_table;
select count(*) from emp_table;
then output both counts to a file (ie a .txt or .dat not concerned) like so:
stf_table count: 47830
emp_table count: 36462
difference: 11368
counts match: FALSE
Granting permissions is the correct thing to do however as you state this is not possible:
one solution could be to do it at the command line using scripts.
(the biggest drawback is the username & password would be embedded in the script for all to see, so make sure the scripts are appropriately secured)
first create 2 scripts:
a.sql:
b.sql:
now create a script file extract.bat to get the output:
now simply execute
extract.batat the command prompt