Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6565449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:05:44+00:00 2026-05-25T14:05:44+00:00

I have table ‘stf_table’ under the schema ‘staff’ with username ‘staff’. I have table

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:05:44+00:00Added an answer on May 25, 2026 at 2:05 pm

    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:

    set timing off
    set feedback off
    set pages 0
    select count(*) from stf_table;
    exit
    

    b.sql:

    set timing off
    set feedback off
    set pages 0
    select count(*) from emp_table;
    exit
    

    now create a script file extract.bat to get the output:

     @echo off
     FOR /F "usebackq delims=!" %%i IN (`sqlplus -s username/password@db_a @a.sql`) DO set resulta=%%i 
    
     FOR /F "usebackq delims=!" %%i IN (`sqlplus -s username/password@db_b @b.sql`) DO set resultb=%%i 
    
     set /a diff=%resulta%-%resultb%
    
     echo stf_table count %resulta% 
     echo emp_table count %resultb%
     echo difference %diff%
    
     IF %diff%=0 (
     echo Counts match TRUE
     ) ELSE (
     echo Counts match FALSE)
    

    now simply execute extract.bat at the command prompt

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table A and table B. Both of them have the same fields.
I have table in which I am inserting rows for employee but next time
I have table in my database which has fields of ID,NAME,CONTEXT. I am showing
I have table in an MS Access database that looks like this: ID Symbol
I have table Owner in my database where one of the field (System) saved
I have table with around 70 000 rows. There is 6000 rows that i
I have table and this table contain result column with some entries. I just
I have table with 300 000 records (MyISAM). I get record from this table
I have table of data that is sorted as follows: Item | Sample |
I have table View with grouped style with three sections. Get information from dictionary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.