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
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:
We can also see them like this:
And use them in PL/SQL: