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 7964737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:57:53+00:00 2026-06-04T05:57:53+00:00

I have a task of copying the data from one database to another.I don’t

  • 0

I have a task of copying the data from one database to another.I don’t have privileges to create DB Link.So, I have achieved this task using COPY command in shell script. But now, I need to compare the count of records between the databases. I used to do this manually. But now,I want to automate this.

As per my knowledge, Sqlplus allows me to connect to one database at a time. But I want something like

sqlplus -s un/pwd@sid <<EOF
 SELECT count(*) FROM table1 WHERE column1 = 'abc'  -- first database
 UNION ALL
 SELECT count(*) FROM table1 WHERE column1 = 'abc';  -- second database
exit
EOF

Is it possible to omit sqlplus string and add it in the query?

Thanks,
Savitha

  • 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-06-04T05:57:55+00:00Added an answer on June 4, 2026 at 5:57 am

    You might want to use sqlplus substitution variables to store the query results:
    http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch5.htm#sthref1114

    These variables are global to a SQL*Plus instance, so they retain their values upon connecting to another database.

    Example:

    SQL> variable var1 number
    SQL> variable var2 number
    SQL> conn a/b@ccc
    Connected.
    SQL> begin
      2  select 1111 into :var1 from dual;
      3  end;
      4  /
    
    PL/SQL procedure successfully completed.
    
    SQL> print var1
    
          VAR1
    ----------
          1111
    
    SQL> conn a/b@ddd
    Connected.
    SQL> print var1
    
          VAR1
    ----------
          1111
    
    SQL> begin
      2  select 2222 into :var2 from dual;
      3  end;
      4  /
    
    PL/SQL procedure successfully completed.
    
    SQL> print :var2
    
          VAR2
    ----------
          2222
    
    SQL> 
    

    We can also see them like this:

    SQL> print :var2 :var1
    
          VAR2
    ----------
          2222
    
    
          VAR1
    ----------
          1111
    
    SQL> 
    

    And use them in PL/SQL:

    SQL> set serveroutput on
    SQL> declare
      2  v1 number := :var1;
      3  v2 number := :var2;
      4  begin
      5     dbms_output.put_line('The difference is: '||to_char((v2-v1)));
      6  end;
      7  /
    The difference is: 1111
    
    PL/SQL procedure successfully completed.
    
    SQL>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a task to transfer text files from one pc to another using
I am new this sharepoint development and i have task in hand to do
I have this task for the project with 4 nested subprojects using Maven: For
I have a rake task that uploads a list of files via ftp. Copying
I have been given a task of copying millions of folders individually through threading
I have a bat file copying files from current machine to mapped network drive
i have task which takes a parameter and has three modes of results Example
I have task involving reading SAS .xpt files using .NET. For that I'm using
I have a task of parsing a simple XML-formatted string in a MySQL stored
I have a task to make a survey to be displayed in SharePoint 2007

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.