In windows batch file,how to check if connection to db is successful or not
I want to do some operations in batch file. So i use command "sqlplus usr/pwd@con @operation.sql" to in the batch file. But how can i check if i connect successfully? The %ErrorLevel% is always 0
Change your batch script as follows:
(P.S. You could prompt for the values in the batch file as well)
file: test.bat
@echo off
sqlplus /nolog @operation.sql <username> <password> <alias>file: test.sql
define username='&1'
define password='&2'
define alias='&3'
whenever sqlerror exit failure;
connect &username/&password@&alias
whenever sqlerror continue;Now you should get a failure message as a result of:
whenever sqlerror exit failure;you can also exit with a specific value
whenever sqlerror exit -5;
Similar Messages
-
Is there any command in windows batch file similar to the unix grep command
Hi,
I have a batch file which will return status of the Database to a file ex: "OPEN". Now I want to read this output file and check for the "OPEN" string from another batch file. any suggestions?. This is similar to "grep" command in unix. I want this to be done in windows batch file.
This is my actual batch file
rem -- Description: Check whether the Database is UP
rem -- Usage:
rem -- ORACLE_SID is input parameter for the file
rem --
rem --start of batch file
@echo off
set ORACLE_SID=%1
echo connect plp/ltd1plp@%1
echo set cmdsep on
echo set cmdsep '"'; --"
echo set term on
echo spool c:/status_log.log
echo select status from v$instance;
echo spool off
) | sqlplus /nolog
rem --end batch file
Thanks.The same link from [google cache|http://209.85.229.132/search?q=cache:EJrm9tgj0a8J:www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/find.mspx+windows+find&cd=1&hl=en&ct=clnk&client=opera]. Also you can use help:
find /? -
Is it possible to call a windows batch file from PL/SQL
Hi gurus,
Would require your help.Is it possible to call a windows batch file from PL/SQL??If yes can you give an example for the same or any workaround for the same.
Regards
VijayHi!
Youn need some extproc related entries in you listener.ora and tnsnames.ora file.
*1. In the listener.ora:*
Defining the listener process is done in two parts.
The information contained in each listener differs!!!
The first part is as follows:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = extproc)) <--- *ADD THIS LINE
(ADDRESS = (PROTOCOL = TCP)(HOST = yourhostname)(PORT = 1521))
)The seoncd part is as follows:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = YOUR_GLOBAL_DBNAME)
(ORACLE_HOME = c:\oracle\product\10.2.0) <-- THIS IS YOUR ORACLE_HOME
(SID_NAME = YOUR_SID) <-- SID
(SID_DESC = <--- ADD THIS LINE
(SID_NAME = PLSExtProc) <--- ADD THIS LINE
(ORACLE_HOME = c:\oracle\product\10.2.0) <--- ADD THIS LINE AND EDIT TO YOUR ORACLE_HOME
(PROGRAM = extproc) <--- ADD THIS LINE
(ENV = "EXTPROC_DLLS=ANY") <--- ADD THIS LINE
) <--- ADD THIS LINE
)*2. In the tnsnames.ora you need to add the following entry:*
*(The KEY value entered must be match to the KEY value entered int the listener.ora file!)*
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = extproc))
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)Finally you need to restart your listiner. After restarting there will be a service called "PLSExtProc" in your listener.
This are only examples for extproc configuration, your tnsnames.ora and listener.ora can be differs.
FIRST MAKE MAKE A BACKUP OF YOUR ORIGINAL tnsnames.ora AND listener.ora FILES
For more information please check metalink note 68061.1 "EXTPROC: Creating External Procedures on Windows NT"
Bestr Regards
Norbert -
Batch file - how to Date & Time Format as January 6, 2014 - 8:54 PM Eastern
Batch file - how to Date & Time Format as January 6, 2014 - 8:54 PM Eastern
Hi Dhiravia,
If you want to convert the month format, please refer to the batch script below:
SET Month=%DATE:~4,2%
if %Month%==01 set Month=JAN
if %Month%==02 set Month=FEB
if %Month%==03 set Month=MAR
if %Month%==04 set Month=APR
if %Month%==05 set Month=MAY
if %Month%==06 set Month=JUN
if %Month%==07 set Month=JUL
if %Month%==08 set Month=AUG
if %Month%==09 set Month=SEP
if %Month%==10 set Month=OCT
if %Month%==11 set Month=NOV
if %Month%==12 set Month=DEC
echo %Month%
To convert the date format via cmd, please also check this article:
http://myblog4fun.com/archive/2012/01/06/getting-the-current-date-and-time-from-bat-files.aspx
If there is anything else regarding this issue, please feel free to post back.
Best Regards,
Anna Wang
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
Maxl within Windows Batch File
Hello,
I am trying to schedule an Automatic Essbase Archiving command . Function is to Disable connects , Archive , Unarchive and Enable connects . I know the Maxl commands which perform this action but just wanted to make sure how to portray this within a Windows Batch file.
Within the Batch file , abc.bat can I insert those commands . To enter the shell we need essmsh command , but I didnt wanted to get into decrypting , encrypting the ID etc to do that . So is there a way to get it done within the Windows batch file ?
Thanks !!Yes its Straight forward case ,create a batch file which call the maxl script.The batch file should contain the user id and password of Essbase and the maxl script should contain the parameters of Essbase archiving
The content of batch file for Essbase archiving process
echo off
set ESSUSER=admin
Set ESSPWD=Password
set ESSSERVER=localhost
set ESSAPP=Sample
set ESSDB=Basic
SET ESSBASE SERVER PATH=D:\Hyperion\Middleware\EPMSystem11R1\products\Essbase\EssbaseServer
set MaxlScript=D:\Hyperion\Middleware\user_projects\epmsystem1\Essbaseserver\essbaseserver1\bin
essmsh "D:\Archieve.mxl" %ESSUSER% %ESSPWD% %ESSSERVER%
===================================================================================================
Maxlscript Content for Archieving
spool on to "D:/bck.log";
set timestamp on;
login $ESSUSER $ESSPWD on $ESSSERVER;
display session all;
alter system kill request all;
alter system logout session all force;
export database $essApp.$essDB all data to server data_file 'd:\alldata.txt';
alter database $essApp.$essDB force archive to file "D:/sample.arc";
alter database $essApp.$essDB end archive;
spool off;
logout;
exit;
Similarly can you create batch files for Cube restoration .I hope the above example helps you
Thanks,
Sreekumar Hariharan -
Call Oracle Stored Procedure with Parameters from Windows Batch File
Hi,
I have an oracle procedure that requires two parameters to execute, start date and end date as such:
CREATE OR REPLACE PROCEDURE insert_orders(
pSTART_DT IN varchar2
, pEND_DT IN varchar2
I want to create a windows batch file to execute the procedure but want to be able to specify the parameters (ie start and end dates) in the batch file as opposed to changing the sql file that the batch file uses to execute the procedure but I don't know what the syntax is. I tried the following but it still doesn't work.
Sql File: call_insert_orders.sql
execute insert_orders('&1','&2');
exit
Batch File:
sqlplus username/password @call_insert_orders.sql %01-jan-2010% %01-jan-2011%
When I execute the batch file, my DOS window still prompts me to enter value 1 so I think it recognizes that there is a variable being used but is not able to fill in the actual value I specify. I'm not an experienced DOS/Windows Batch File person so I'm guessing it's my syntax that's screwed up. There is not a lot of documentation on this subject matter hence my post on this forum. Any helps would be appreciated.
ThanksHello,
Just try the same DOS command without all the % sign.
In MS-DOS, the % at the beginning and at the end of a string are for variables. Which means your batch is looking for a variable called 01-jan-2010 and a variable called 01-jan-2011, but those are the values you want to pass, not the name of variables.
As they are not defined, nothing is passed to the sqlplus script, and that is why you are prompted for values.
Hope it will help.
Regards,
Sylvie -
Is it possible to call a windows batch file from PL/SQL block ??
Hi gurus,
Would require your help.Is it possible to call a windows batch file from PL/SQL block ??If yes can you give an example for the same or any workaround for the same.
Regards
VijayYou didn't specify a database version, but if you are 10g or higher, it's quite straightforward using an external job type in DBMS_SCHEDULER. Funnily enough i'm looking at something similar myself at the moment.
Useful guide to some of the issues here Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch files -
Problem in connecting to sqlplus from windows batch file (DOS)
Hi All,
We have a new 10g Oracle database installed on windows server. I am trying to write a windows batch file to
1) Connect to SQLPLUS
2) Execute a script
3) Disconnect from SQLPLUS.
Example File Name:- execsql.bat
SET ORACLE_SID=CAUT
SET SCHEMA_IN=%1
SET PASS=DEV
SET script=%2
sqlplus %SCHEMA_IN%/%PASS%@%ORACLE_SID% @%script%
if %errorlevel% NEQ 0 echo ERROR: %ERRORLEVEL% else echo OK
Now if i run this bat file like :- execsql.bat DEV script1.sql
DEV= schema name,
script1.sql = this file contains select * from dual;
The code runs fine, but if i change dual to dual1 the sql error's out but not able to catch the error in the batch file.
Reason why i would like to catch the error is this batch file would be scheduled through Autosys job scheduler and for autosys any exit code >0 is an error. Please help me in rewriting this batch script.
Thanks
Sam.Hello,
What if you run this in SQL*Plus before you run the SELECT:
whenever sqlerror exit failure -
Where windows batch file which log off windows lies ?
where windows batch file which log off windows lies ?
to which me can call from java code to log off my pc?You should use a brute-force algorithm on the on/off switch on your pc. I suggest a rate of 30 hits per minute.
-
Where windows batch file lies which log off windows ?
where windows batch file lies which log off windows ? wana log off my pc from java code
grc.com has a program (very small) that does it. The program is called "wizmo" and is written in Assembly.
If you are using Windows NT/2000/XP you can get a program in MS Windows Resource Kit called "shutdown.exe" but the program does only the shutdown job. You must manually turn the machine off. -
How to check weather a material created is active or not
Dear Friends
1 How to check weather a material created is active or not.
2 MIGO standard document has a check button, can we have similar check button in other documents like Purchase requisition.
3 In case of material valuation is Standard (Price control), the costing is done on the basis of the Standard Price or actual cost of the raw material.
I will be thankful for your advice.
Sanjeev1 How to check weather a material created is active or not.
There is a Blue "i" button for the Material, pls click that it will show you the current status..
2 MIGO standard document has a check button, can we have similar check button in other documents like Purchase requisition.
for PR you can see the check button( CtrlShiftF3) beside personal settings -
How to check whether set up tables are filled or not
Hi Gurus,
How to check whehter set up tables are filled or not?
Cheers,
Reddy.Hi Reddy.......
And another point I want to make u clear............LBWQ is not the Delta Queue.............Delta queue is RSA7...............it comes into play in delta loading.......LBWQ is Extraction Queue.........While delta loading....if we use the Update mode Queued Delta........then any Changes will not directly get updated in the Delta queue.....For the Delta set up.........
1) First u hav to run init with data transfer(After filling the set up table)
2) After that any Changed ........will be recorded in the Extraction Queue(LBWQ)........
3) After a certain number of records get accumulated in LBWQ........We hav to run V3 jobs to bring the data in the Delta queue(RSA7)...
Check this.....
Re: question on LBWQ and RSA7
Regards,
Debjani..... -
How to check wheather the project is having 'AUC' or not.
Hi friends,
How to check wheather the project is having 'AUC' or not.
Regards,
Safiq.Hi Basha ,
as per my knowledge , WBS will have AUC ,Settlement rules etc, so u need to check asset tables based on the WBS element .
regards
Prabhu -
How to check SQL Tuning Advisor task is exist or not
How to check SQL Tuning Advisor task is exist or not using DBMS_SQLTUNE,
I want to remove SQL Tuning Advisor task only if it is exist using DBMS_SQLTUNE.DROP_TUNING_TASK functionTwo approaches.
1. Look up in DBA/USER_ADVISOR_TASKS, if it exists, drop it.
2. Drop it, ignore the exception
3. Drop it, catch the exception (specific exception if you want to rightly avoid such constructs as when others then null) obviously within an inner block is you want to catch and then move on to do other work.
SQL> declare
2 e_no_such_task exception;
3 pragma exception_init(e_no_such_task,-13605);
4 procedure forgetaboutit
5 as
6 begin
7 null;
8 end;
9 begin
10 begin
11 dbms_sqltune.drop_tuning_task('NON_EXISTENT_TASK');
12 exception
13 when e_no_such_task then
14 forgetaboutit;
15 end;
16 -- do something else
17 null;
18 end;
19 /
PL/SQL procedure successfully completed.
SQL> P.S. Ignore procedure forgetaboutit - just amusing myself... -
How to check connector connectivity in OIM 11g
Hi All,
How to check connector connectivity in OIM 11g. In erlier version we have XIMDD from where we can test connectivity. But I dont see anything in 11g.
Thanks.Noway ! !
Go to:
*<Oracle-Weblogic-Middleware-Home>\Oracle_IDM\server\features\Xellerate.zip* & you can find the XIMDD.war
Maybe you are looking for
-
Ipod Classic Re-Formatted In Disk Utility Not Being Recognized
I last posted about this question 4 months ago on this forum and still havent received an answer that works. My Silver Ipod Classic 80GB was used to update the OS on my computer. Foolishly I partitioned the disk on it using disk utility and updated m
-
Hi Folks, I am sending data to the webservice using SOAP receiver. In the runtime workbench I can see the message as successfull, but the end user is claiming that , he didn't get the data from XI. What could be the possible reason for this? Where mi
-
Auto call timer announcement and cut off
I have been asked to come up with a comms solution for detention cells, where the detainee has the right to make a 30min call to their legal rep. The system would ideally announce at the start of call "your call is limited to 30 mins", then after 28
-
Banks Agree to Erase Debts From Credit Reports After Bankruptcies
FYI - "Under federal law, once a borrower has erased a debt in bankruptcy, banks are required to update the credit reports to indicate that the debt is no longer owed, and remove any notation of "past due" or "charged off."" http://www.nytimes.com/20
-
TaskId 'XYZ' has only execution times in the past it can not be scheduled
Dear Experts I'm trying to schedule the job, but while schuduling the job its saying "taskId 'b7611dee12bc714b421b77212cc16329' has only execution times in the past and thus it can not be scheduled. I don't understand whats wrong here. below is code