Home » SQL & PL/SQL » SQL & PL/SQL » executing a stored procedure from batch file
executing a stored procedure from batch file [message #194289] Thu, 21 September 2006 07:28 Go to next message
vandana173
Messages: 7
Registered: August 2005
Location: india
Junior Member
Hi,

How to execute a stored procedure from batch file?
What is the code for this?

Thanks
Vandana
Re: executing a stored procedure from batch file [message #194298 is a reply to message #194289] Thu, 21 September 2006 07:39 Go to previous messageGo to next message
kimant
Messages: 201
Registered: August 2006
Location: Denmark
Senior Member
And which operating system do You have?

try

sqlplus scott/tiger@orcl @my_procedure

Br
Kim
Re: executing a stored procedure from batch file [message #194310 is a reply to message #194298] Thu, 21 September 2006 08:04 Go to previous messageGo to next message
vandana173
Messages: 7
Registered: August 2005
Location: india
Junior Member
I am working on windows XP
Re: executing a stored procedure from batch file [message #194333 is a reply to message #194289] Thu, 21 September 2006 09:51 Go to previous messageGo to next message
rigatonip
Messages: 50
Registered: December 2005
Member
see if this link helps out....

http://asktom.oracle.com/pls/ask/f?p=4950:8:336766453588041902::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:594023455752
Re: executing a stored procedure from batch file [message #194339 is a reply to message #194289] Thu, 21 September 2006 10:19 Go to previous message
rigatonip
Messages: 50
Registered: December 2005
Member
Here's another example showing how to run a sql statement from a batch file.

http://orafaq.cs.rmit.edu.au/scripts/win/runsql.txt

You could modify it to something like this to take a procedure name as an argument.

@echo off
rem ----------------------------------------------------------
rem Filename:   RunSql.bat
rem Purpose:    Run SQL*Plus script from DOS batch file
rem Date:       05-Mar-2002
rem Author:     Frank Naude, Oracle FAQ
rem ----------------------------------------------------------


rem Purpose:    Run SQL*Plus script from DOS batch file

rem -- Accept command line arguments --
rem Note: %1 is the first command line argument, %2 the second, etc.

if "%1" == "" goto Usage
set PNAME=%1
echo Command Line Argument: %PNAME%


rem -- Create sql script
echo connect scott/tiger@amsaa   >%0.tmp
echo begin                      >>%0.tmp
echo %PNAME%;                   >>%0.tmp
echo end;                       >>%0.tmp
echo /                          >>%0.tmp
echo exit                       >>%0.tmp

rem -- Run sql script --
sqlplus /nolog @%0.tmp

rem -- Cleanup -- 
del %0.tmp

goto End

:Usage
  echo Usage: %0 procedure_name

:End
Previous Topic: Dynamic SQL Question
Next Topic: Check for Existance of Objects
Goto Forum:
  


Current Time: Mon Feb 17 23:29:38 CST 2025