Making batch file to execute a procedure
Hi,
I have to make a batch file which when clicked shoud do the following
conn scott/tiger@orcl
exec procedure1
exit from oracle
Please help me how to proceed wiht the same
Thanks in Advance
Create the batch file as follows:
echo exec procedure1; | sqlplus scott/tiger@orcl
Similar Messages
-
Making batch files to execute java programs in windows
In my comp sci class, i found a folder with a batch file, an application file, and all class files necessary to run the program.
how do i take my java program and make a batch file to run it (in dos) like that program in my comp sci class?Okay, here are your steps for running a java program from a batch file:
1) Open Notepad
2) type the following:
set JAVA_HOME=C:\j2sdk1.4.0_03 // specify the path where your jdk is
set path=%JAVA_HOME%\bin;.
javac {-classpath .;one.jar;two.jar} YourProgramName.java
java {-classpath .;one.jar;two.jar} YourProgramName
The stuffs inside {} is not necessary if your program doesnt use any .jar files.
3) Save the notepad as mybatch.bat in the directory where your Java program is located.
4) In the DOS prompt, go to the directory where you have .java and .bat files
(use 'cd' command)
5) Now, type mybatch.bat and press ENTER.
Thatz it. Your program runs like a charm now!!!
(provided the compiler is pleased with ur code :)
-- layman's pal -
Executing batch file from Java stored procedure hang
Dears,
I'm using the following code to execute batch file from Java Stored procedure, which is working fine from Java IDE JDeveloper 10.1.3.4.
public static String runFile(String drive)
String result = "";
String content = "echo off\n" + "vol " + drive + ": | find /i \"Serial Number is\"";
try {
File directory = new File(drive + ":");
File file = File.createTempFile("bb1", ".bat", directory);
file.deleteOnExit();
FileWriter fw = new java.io.FileWriter(file);
fw.write(content);
fw.close();
// The next line is the command causing the problem
Process p = Runtime.getRuntime().exec("cmd.exe /c " + file.getPath());
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = input.readLine()) != null)
result += line;
input.close();
file.delete();
result = result.substring( result.lastIndexOf( ' ' )).trim();
} catch (Exception e) {
e.printStackTrace();
result = e.getClass().getName() + " : " + e.getMessage();
return result;
The above code is used in getting the volume of a drive on windows, something like "80EC-C230"
I gave the SYSTEM schema the required privilege to execute the code.
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
GRANT JAVAUSERPRIV TO SYSTEM;
I have used the following to load the class in Oracle 9ir2 DB:
loadjava -u [system/******@orcl|mailto:system/******@orcl] -v -resolve C:\Server\src\net\dev\Util.java
CREATE FUNCTION A1(drive IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'net.dev.Util.a1(java.lang.String) return java.lang.String';
variable serial1 varchar2(1000);
call A1( 'C' ) into :serial1;
The problem that it hangs when I execute the call to the function (I have indicated the line causing the problem in a comment in the code).
I have seen similar problems on other forums, but no solution posted
[http://oracle.ittoolbox.com/groups/technical-functional/oracle-jdeveloper-l/run-an-exe-file-using-oracle-database-trigger-1567662]
I have posted this in JDeveloper forum ([t-853821]) but suggested to post for forum in DB.
Can anyne help?Dear Peter,
You are totally right, I got this as mistake copy paste. I'm just having a Java utility for running external files outside Oracle DB, this is the method runFile()
I'm passing it the content of script and names of file to be created on the fly and executed then deleted, sorry for the mistake in creating caller function.
The main point, how I claim that the line in code where creating external process is the problem. I have tried the code with commenting this line and it was working ok, I made this to make sure of the permission required that I need to give to the schema passing security permission problems.
The function script is running perfect if I'm executing vbs script outside Oracle using something like "cscript //NoLogo aaa1.vbs", but when I use the command line the call just never returns to me "cmd.exe /c bb1.bat".
where content of bb1.bat as follows:
echo off
vol C: | find /i "Serial Number is"
The above batch file just get the serial number of hard drive assigned when windows formatted HD.
Same code runs outside Oracle just fine, but inside Oracle doesn't return if I exectued the following:
variable serial1 varchar2(1000);
call A1( 'C' ) into :serial1;
Never returns
Thanks for tracing teh issue to that details ;) hope you coul help. -
How to create Batch file to execute sql scripts
Hi friends,
i want to create batch file to execute all my .sql scripts.
I have all table ( all table scripts in single file ) ,Udds ( all udds in single file ) ,Stored procedures( separate file for each SPs ),Functions ( Separate file for each Functions ),Triggers and views scripts in .SQL file.
can anybody tell me how to create batch file for executing all these scripts in sql server ?.
while executing, it should ask Database name,server name, password. if these details are given then it should execute my all scripts in given database
, if any error thrown then that error and procedure name alone have to move to separate log file..
Please help me if this possible or any other easy way to do this..
Thanks - RaviHi Mate.
can i save the below details in my batch file parmantly, so that i don't need to provide the details agains again in CMD while i execute this. Please help
set /p SName=Server Name :
set /p UName=User Name :
set /p Pwd=Password :
set /p DbName=Database Name
If i am providing the details before execution of this bat file it will throw error. -
Batch file to execute java code
Hi,
I need to write a batch file to execute a sequence of java applications.
The problem i face is in addition to the usual libraries I am also using certain jar files i downloaded like the mail interface etc.
When i just compile a java code using a simple batch file giving the path of the compiler and the java code, it fails citing not knowing the location if the packages.
could anyone please let me know what i need to do. Is there like a skeleton that i might find somewhere for this operationdexterity wrote:
Hi,
I need to write a batch file to execute a sequence of java applications.
The problem i face is in addition to the usual libraries I am also using certain jar files i downloaded like the mail interface etc.
When i just compile a java code using a simple batch file giving the path of the compiler and the java code, it fails citing not knowing the location if the packages.
could anyone please let me know what i need to do. Is there like a skeleton that i might find somewhere for this operationSet the classpath correctly at runtime.
Why do you need the location of your compiler? Are you compiling or running? If you are compiling go look at Ant. -
Batch file not executing in BODS Job
Hi friends,
I have created a batch file to create a text file in a directory. I ran it manually and it worked fine i.e a txt file was created, However when I used the batch file in script in BODS job, It's not being executed.
The script being used is as follows ( I have tried both, Both worked manually but not in Job, the job ran successfully without desired output )
print(exec('C:\xxx\testdir.bat ','',0));
exec('C:\xxx\testdir.bat ','',8);
testdir.bat has the below txt code
cd C:\xxx\yyy dir *.xml /b > dir.txt
Thanks and Regards
AnilWhat have you changed between
However when I used the batch file in script in BODS job, It's not being executed
and
The Job was successfully executed but an empty dir.txt was created with no files. -
Pass Passord Variable to a Batch File using Execute Process Task
I have an FTP batch file that I want to execute using Execute Process Task. The content of the ftp (ftpscript.cmd) is as below:
open ftpsite
UserName
Password
ASCII
get file c:\temp\test.txt
bye
Using SSIS Execute process task, I was able to download data. I configured the Execute Process task as follows:
Executable: ftp.exe
Arguments: -s:"c:\temp\ftpscript.cmd"
The above works fine. But the problem is that I don't want to store the password value in the batch file for security/policy reasons. Please, is there a way I can pass the password value to the ftp executable or the batch file at run time?
I know how to get and store variables in SSIS but I don't know how to pass this kind of variable to the batch file just before execution.
Any suggestions will be appreciated. Thanks.you can dynamically generate the source (CMD) for the FTP and delete after the execution. The password can be stored in a secure database for example, not 100 % secure, but the best you can do.
Another option I did was an encrypted VBScript (also quite easy to open in plain text to some people).
Finally it can be a binary e.g. an EXE with the FTP called as process in it.
Arthur My Blog -
Two questions: Executing batch files and executing a JAR on boot-up.
I'm working with Windows XP and and currently I'm having a friend test this on Vista as well. I can't seem to find how to execute a batch file using Runtime.exec(). So far I've been passing the absolute pathname of the batch file as the argument to exec(), but it doens't seem to run, so I'm assuming there's another way.
Second question, how do I get a JAR file to start running whenever the user turns on the PC?
Thanks.I'm working with Windows XP and and currently I'm
having a friend test this on Vista as well. I can't
seem to find how to execute a batch file using
Runtime.exec(). So far I've been passing the
absolute pathname of the batch file as the argument
to exec(), but it doens't seem to run, so I'm
assuming there's another way.Are you using just Runtime.exec() or have you tried Runtime.getRuntime().exec()? If not, try that and see what happens.
Second question, how do I get a JAR file to start
running whenever the user turns on the PC?As far as I know, you can't do that programatically. You have to edit settings on your computer but I am not entirely sure.
Thanks. -
Calling Remote Batch File Using 'Execute Process Task'
I have a remote batch file on machine B that I need to execute using 'Execute process task' control from a package on machine
A.
How can i achieve this...You also need to make sure you run the job using a domain account proxy http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/
Arthur
MyBlog
Twitter -
Cannot call 2 batch files .. executes only one batch and the program exists
Hello,
I am trying to call 2 batch files from the program . due to some reason only first batch file is called and second one is not called . any idea why it is happening.
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import java.io.*;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
public class MyBatchFiles {
public static void main (String args[]) throws Exception {
StringBuffer output = new StringBuffer();
StringBuffer error = new StringBuffer();
try {
//call batch files
Process Process=Runtime.getRuntime().exec("cmd /c start F:\\batch1.bat"); // Batch File Path
Process.waitFor();
BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(cubeBuildProcess.getInputStream()));
BufferedReader errStreamReader = new BufferedReader(new InputStreamReader(cubeBuildProcess.getErrorStream()));
output = new StringBuffer();
error = new StringBuffer();
for(String ProcessLine;(ProcessLine=inputStreamReader.readLine())!=null;)
output.append(ProcessLine);
for(String ProcessLine;(ProcessLine=errStreamReader.readLine())!=null;)
error.append(ProcessLine);
System.out.println("transformer output = " + output);
System.out.println("transformer error = " + error);
if (error!=null){
//calling batch2
Process Process2=Runtime.getRuntime().exec("cmd /c start F:\\batch2.bat"); // Batch File Path
Process2.waitFor();
BufferedReader Process_inputStreamReader = new BufferedReader(new InputStreamReader(Process2.getInputStream()));
BufferedReader Process_errStreamReader = new BufferedReader(new InputStreamReader(Process2.getErrorStream()));
for(String ProcessLine1;(ProcessLine1=Process_inputStreamReader.readLine())!=null;)
output.append(ProcessLine1);
for(String ProcessLine1;(ProcessLine1=Process_errStreamReader.readLine())!=null;)
error.append(cubeCopyProcessLine);
}catch(Exception e) {
e.printStackTrace();
}Thanks
MikeIt's your if statement. Why do you think it could be happening?
-
Very urgent..Can a batch file be executed from a button in application?
HI!
Please this is very urgent..
I want to know wheather it is possible to provide a button in an htmldb application,
that executes a batch(dos .bat file) file from a network location????
Thanks
Asit.
Message was edited by:
user459887It will be possible to do that but I suggest you search the HTML DB Forum first and place your question there rather than in this forum .
Greg -
Keeps asking for rpt file when executing store procedure
Hi all,
I have coded an standard stored procedure but when I execute it, Management Studio keeps asking for .rpt file to save the results. I am using Enterprise 2008 R2.
This is the code:
USE [mydatabase]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_chart](
@parameters)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @query NVARCHAR(4000)
DECLARE @total INT
DECLARE @strDescriptor NVARCHAR(4000)
DECLARE @dsvalues NVARCHAR(4000)
DECLARE @strCache NVARCHAR(2000)
SET @strDescriptor = dbo.udf_chart_derived_descriptor_intotemp(@derivation_Id)
SET @dsvalues = dbo.udf_chart_derived_dynamic_query_fortopn( @derivation_Id,
@cache_Id,
@topn,
@flt_customer_Id,
@flt_user_Id,
@flt_datefrom,
@flt_dateto,
@product_Id
SET @strCache = 'SELECT top ' + @topn + 'PERCENT g.Supplier_Id Supplier_Id
INTO #T_CacheTopN
FROM T_CacheSupp g
WHERE g.Cache_Id = ' + @cache_Id +
' ORDER BY g.Position'
IF @strFilter is null
BEGIN
SET @query = @strCache + ';' + @strDescriptor + ';' +
'DECLARE @total INT;' +
@dsvalues +
'SELECT @total = COUNT(*)
FROM #T_Condition;
SELECT c.Condition_Index, ROUND(COUNT(*)/CAST(@total as float),2)*100
FROM #T_Condition c
GROUP BY c.Condition_Index';
END
ELSE
BEGIN
DECLARE @sqlfilter NVARCHAR(2000)
SET @sqlfilter = dbo.udf_chart_dynamic_query_filter_fortopn(@strFilter,@product_Id,@topn, @cache_Id)
SET @query = @strCache + ';' +@strDescriptor + ';' +
'DECLARE @total INT;' +
@dsvalues +
'SELECT @total = COUNT(*)
FROM #T_Condition;'+ @sqlfilter +
';SELECT c.Condition_Index, ROUND(COUNT(*)/CAST(@total as float),2)*100
FROM #T_Condition c LEFT OUTER JOIN #T_NotWanted d
ON c.Data_Id = d.Data_ID
WHERE d.Data_Id is null
GROUP BY c.Condition_Index';
END
EXEC(@query)
RETURN
END
When I execute:
DECLARE
@parameters NVARCHAR(4000)
execute usp_chart_derived_fortopn @parameters
it asks me for a .rpt file.
Why is that? I am not running a report.
ThanksAs other have said, you have set Results to File.
But since you posted your code, I had a look at it. I was not able to understand why you use dynamic SQL. For instance, this:
SET @strCache = 'SELECT top ' + @topn + 'PERCENT g.Supplier_Id Supplier_Id
INTO #T_CacheTopN
FROM T_CacheSupp g
WHERE g.Cache_Id = ' + @cache_Id + ' ORDER BY g.Position'
Can be written as
SELECT top (@topn) PERCENT g.Supplier_Id Supplier_Id
INTO #T_CacheTopN
FROM T_CacheSupp g
WHERE g.Cache_Id = @cache_Id
ORDER BY g.Position
If you can avoid dynamic SQL, your code becomes easier to maintain, and less vulnerable for nasty surprises.
And if you use dynamic SQL, you should use sp_executesql and pass parameter values as parameters instead of inlining them.
Erland Sommarskog, SQL Server MVP, [email protected]
Links for SQL Server Books Online:
SQL 2008, SQL 2005 and
SQL 2000.
(Just click the link you need.) -
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 -
Hi,
I need help in writing a method that execute a batch file which is in a different directory from my java application and show the result(after executing the batch file) in the java application. Can anyone tell me how to do that?
Thanks,
KhimHi,
Below are the codes in my application. Using these codes, the batch file can execute but I cannot get the output of the result from the batch file. (if I run the batch file from cmd, it shows: "Error: 0 : Cannot authenicate the information after all the attempts")
String cmd = new String();
Runtime rt = Runtime.getRuntime();
System.out.println("Executing VocaliD check..");
cmd="C:\\JNI\\Elva\\debug\\plug.bat";
Runtime rn = Runtime.getRuntime();
Process pc1 = rn.exec(cmd);
String result=new String(pc1.getInputStream().toString ());
System.out.println(result);
The result I got is below:
Executing VocaliD check..
java.io.BufferedInputStream@3179c3
Thanks,
Khim -
Executing a batch file from a jsp
hi,
i have a jsp running on tomcat 3.1
now upon submit, i want a batch file to execute .
how do i do that..( i mean what will be the correct syntax for this ) say the batch file exists in /tomcat/batch/ do i have to give the abosolute path for this or a relative path will do.. ( if the relative path works then, do i have to mention a context for the batch directory in server.xml..
pls help.. this is urgent
thanxHi truptip,
This is the code to execute a batch file or any system command,
Process p = Runtime.getRuntime().exec("shell command you want to exit");
p.waitFor();
In regards to whether you should access it using a relative location, the answer is no. Execution of a batch file is not part of the the webserver, so the webserver's concept of the current directory for the client does not apply.
On a side note I wanted to say that I would highly recommend that you don't put the batch files anywhere on the webserver that is accessible to the user, not that the webserver would execute the code, but it may let out some information that you don't want available.
Hope this is of some help,
James
Maybe you are looking for
-
My HP G70-120EM Laptop with a blueray player will not recognise blueray discs.
my HP G70-120EM Laptop with a blueray player will not recognise blueray discs. Any idea what software update I need?
-
i have recently changed my pasword from a word, to the standard 4 diget pasword. my phone has decided that my pasword is incorect when i know for definate that it is correct! what do i do ?!
-
Colour grade with Kuler RGB or Hex values
Is there a grading/colour correction effect in PPRO which allows you to map midtones/shadows/hilights to an RGB or Hex value such as one acquired through Adobe Kuler? If not that easily, how could one use the swatches (RGB values) from Kuler as a pal
-
Help in obtaining results from database
i have a column containing value as abc's but when i retrieve this value from the database using rs.getString("columnname") i get only abc and not abc's. what is the problem
-
I updated to Yosemite and cannot turn on extensions in Safari
I updated to Yosemite 10.10 on my MacBook Pro and now cannot turn on extensions in Safari (8.0), Preferences, Extensions. When I move the slide button to the "on" position it immediately moves to the "off" position. I turned off all extensions and re