Skip to Main Content
  • Questions
  • SQL Plus from task scheduler TNS Adapter Protocol Error

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Rodrigo.

Asked: April 24, 2017 - 3:12 pm UTC

Last updated: April 26, 2017 - 4:19 am UTC

Version: 11.2.0

Viewed 1000+ times

You Asked

Hello guys,

I'm facing a error which I've never come across.

We have a backup script scheduled to run from a batch file, it is currently giving me a TNS Adapter Protocol Error. Normally I'd think the service isn't running but oddly enough double clicking the batch from windows explorer runs as expected. Anyone knows of anything that executes differently from task scheduler and can help me with this? Thanks in advanced.

and Connor said...

The most common cause is the script is picking up something from *your* environment (eg ORACLE_HOME or PATH etc) that is not being set when run from the scheduler.

So perhaps try adding something like this to the start of your script:

set ORACLE_SID=db122
set PATH=C:\oracle\product\12.2.0.1\bin;%PATH%
set ORACLE_HOME=C:\oracle\product\12.2.0.1

(obviously using values appropriate to your system)

and *then* call rman or sqlplus etc

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Problem Solved

Rodrigo D%27Amorim Lima Siqueira, April 25, 2017 - 5:39 pm UTC

Wow... On spot!

I thought Task Scheduler used the user's environment variables to execute it's tasks, guess I was wrong...

Adding those set commands to my batch solved the issue.

Thank you for your time! :D
Connor McDonald
April 26, 2017 - 4:19 am UTC

Glad we could help

More to Explore

Backup/Recovery

Check out the complete guide to all of the Backup & Recovery techniques in the Oracle Database.