Create batch file containing SQL commands
Hi,
Iam using windows xp... I have 8 *.sql files, all of them contain insert statements and every file takes 40 min to execute and when one finishes i execute the other.
Is there any way that i can combine them and execute at one go..
Now iam using
spool o:\abc.log
@abc.sql
spool off
Can any one help me ..
Any help would be appreciated
Thanks
> all of them contain insert statements and every file takes 40 min to execute
Insert statements!?
All of them totally trash the Oracle Shared Pool.. If only done properly, each would take mere seconds to run and not 40 minutes.
A snip of a benchmark I posted some time ago showing just how utterly wrong it is to code SQL inserts using literal values.
SQL> create table footab( n number );
Table created.
SQL> set timing on
SQL>
SQL> -- doing a 100,000 inserts using a single SQL INSERT with bind variable
SQL> declare
2 sqlInsert varchar2(1000);
3 begin
4 sqlInsert := 'insert into footab( n ) values( :0 )';
5 for i in 1..100000
6 loop
7 execute immediate sqlInsert using i;
8 end loop;
9 end;
10 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:04.91
SQL> -- doing a 100,000 inserts using a 100,000 SQL INSERTs
SQL> declare
2 sqlInsert varchar2(1000);
3 begin
4 -- need to built a unique SQL for each insert
5 for i in 1..100000
6 loop
7 sqlInsert := 'insert into footab( n ) values( '||i||' )';
8 execute immediate sqlInsert;
9 end loop;
10 end;
11 /
PL/SQL procedure successfully completed.
Elapsed: 00:05:21.47
SQL>The second method is what you are using. 1000's of insert statements, each with hard coded literal values to insert.
The first method show how it should be done from the client side - using a single SQL insert with bind variables.
And the result? 5 minutes 21 seconds versus a mere 4.91 seconds!!!
You need to seriously rethink your approach. Abusing Oracle is not how one achieve the spectacular performance and scalability that Oracle is famous for.
Similar Messages
-
Importing schema+ data using a text file containing sql commands
I have the 2012 SQL SVR Mgmt Studio installed. I received a file--snippet below... from an export of our current DB provider, Advantage. I know I have to edit a lot of commands, but my question is quite simple--how do I use a text file with commands in it
like below to create tables, columns and load data into SQL SVR.
---data.txt file contents----
-- Table Type of Beneficiary is ADT
Create Table Beneficiary(
PlanId Char( 9 ),
Hash Integer,
Line1 Char( 128 ),
Line2 Char( 128 ),
Batch Char( 16 ) );
EXECUTE PROCEDURE sp_CreateIndex90( 'Beneficiary', 'LAC_LACV1_Beneficiary.adi', 'KEY1', 'Hash;PlanId', '', 2051, 4096, NULL );
INSERT INTO "Beneficiary" VALUES( 'LACV1', 983, 'Judith Pursifull~Spouse~100~~~', 'Michael Pursifull~Son~50~Thomas Pursifull~Son~50', '761011042' );
INSERT INTO "Beneficiary" VALUES( 'LACV1', 996, 'Anna Brownlow~Spouse~100~~~', 'Kaitlin Brownlow~Daughter~85~Lawanda Brownlow~Mother~15', '49036615' );
INSERT INTO "Beneficiary" VALUES( 'LACV1', 1005, 'Weldon Shelton~Other~50~Star Shelton~Other~50', 'Danica Shelton~Sister~50~Ryan Shelton~brother~50', '109075816' );
INSERT INTO "Beneficiary" VALUES( 'LACV1', 1031, 'Donald D Duffy~Spouse~100~~~', 'Brandon M Duffy~Son~100~~~', '219979254' );
INSERT INTO "Beneficiary" VALUES( 'LACV1', 1063, 'Lynne Roffino~Other~50~John Roffino~Other~50', 'Katy Roffino~Sister~50~Margaret Roffino~Sister~50', '604232358' );
INSERT INTO "Beneficiary" VALUES( 'LACV1', 1062, 'John Teaven Redstone~Spouse~100~~~', '~~~~~', '482024691' );
INSERT INTO "Beneficiary" VALUES( 'LACV1', 1032, 'Judith Anne Brown (for cat care)~Other~50~Judith Ann (Kappler) Barklage~Other~50', 'LaVerne Cocke (for cat care)~Friend-PantegoBibl~50~~~', '358324107' );
-- Table Type of Date is ADT
Create Table Date(
Hash Integer,
PlanId Char( 9 ),
Type Char( 24 ),
Date Date,
Override Logical,
Batch Char( 32 ) );
EXECUTE PROCEDURE sp_CreateIndex90( 'Date', 'LAC_LACV1_Date.adi', 'KEY1', 'Hash;Date;PlanId;Type', '', 2051, 4096, NULL );
INSERT INTO "Date" VALUES( 1018, 'LACV1', 'HARDSHIPEND', '2010-02-20', False, '20090820-9414719' );
INSERT INTO "Date" VALUES( 1018, 'LACV1', 'HARDSHIPSTART', '2009-08-20', False, '20090820-9414719' );
INSERT INTO "Date" VALUES( 1001, 'LACV1', 'HARDSHIPEND', '2010-02-06', False, '20090806-9371968' );
INSERT INTO "Date" VALUES( 1001, 'LACV1', 'HARDSHIPSTART', '2009-08-06', False, '20090806-9371968' );
INSERT INTO "Date" VALUES( 1022, 'LACV1', 'LUMPSUMDISTRIBUTION', '2009-07-21', False, '20090721-9337640' );
charles.leggettefrom an export of our current DB provider, Advantage.....
-- Table Type of Date is ADT
Create Table Date(
Hash Integer,
PlanId Char( 9 ),
Type Char( 24 ),
Date Date,
Override Logical,
Batch Char( 32 ) );
Hello Charles,
The SQL Syntax especially for DDL commands are different between MS SQL Server and Advantage Database, so you have to modify them to get them work.
As David already wrote we don't have a stored procedure "sp_CreateIndex90" in SQL Server, you may remove these commands, and we also don't have a data type "Logical", next could be "bit"
Olaf Helper
[ Blog] [ Xing] [ MVP] -
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. -
Unable to run a Batch File Operating System Command
Using XI 3.0, I am unable to run a Batch File Operating System Command After Message Processing.
My Batch file:
gpg -se -r BOA3RSKY --armor --passphrase-fd 0 %1 < C:\Progra~1\GNU\GnuPG\gpgin
My Command Line (ID scenario)
exec "cmd.exe /c C:\Progra~1\GNU\GnuPG\boagpg.bat %F"
If I execute
exec "cmd.exe /c type C:\Progra~1\GNU\GnuPG\boagpg.bat >xis.txt"
It displays the contents of boagpg.bat file in xis.txt.
I just don't understand why when I run the batch file, I would expect an %F.asc encrypted file in the same directory as the %F unencrypted file.
Any ideas?
or will I need Basis to create commands that will allow me to run GPG from XI Command Line?Check this links if its helpful
http://help.sap.com/saphelp_nw04/helpdata/en/bb/c7423347dc488097ab705f7185c88f/frameset.htm
/people/sap.user72/blog/2004/01/30/command-line-help-utility
Check this thread a similar problem
Process Integration (PI) & SOA Middleware
Note 841704 - XI File & JDBC Adapter: Operating system command
http://service.sap.com/sap/support/notes/841704
Try to see the below links
/people/michal.krawczyk2/blog/2005/08/17/xi-operation-system-command--error-catching
OS Command on FTP
OS command line script - Need help
FTP - Run OS Command before file processing
Note: reward points if solution found helpfull
Regards
Chandrakanth.k -
Calling a batch file in sql scripts
Hi friends,
I am looking for a way to call any batch file in sql scripts.I am avoiding to use DBMS_SCHEDULER package because my application server and database server are diifferent .
I am using the sql script in application server.plz help.<ironic>
Ah, I see. This of course explains everything.
</ironic>
Now to be serious: there is no way to run a batch script from SQL. The tools which submit SQL Statements to the database are often capable of doing so; host in SQL*Plus can issue OS commands, the host builtin in Forms does it too, and with dbms_scheduler you can run a shell script on the database server.
So depending on the tools you are using there are several ways to run OS commands. So far you didn't tell us what you want to do with what tools in which version you want to do it. So to only answer is: this is not possible. You cannot run a batch script from plain SQL.
cheers -
Hi
Is this the correct way to create batch file
ESSMSH filepath\filename.mxl and save with .bat extension
example ---> ESSMSH C:\Documents and Settings\mpankhan\My Documents\Maxl scripts\inc.mxl
were inc.mxl is the file name
thanks in advanceHi,
Yes it is ESSMSH filepath and filename, well as long as the environment path/variable is correct so you can just enter ESSMSH from command line, you can easily check that just by going to command line and enter ESSMSH.
You may need to enclose the fiilepath and name in quotes if you have spaces in your path.
Cheers
John
http://john-goodwin.blogspot.com/ -
hi,
can anybody tell me how to create batch file which will have username and password for ftp.
i want copy file from remote server to local server using ftp.
i want to create batch file which will perform all this taks..
please help me.
thanks in advance,
Chetan S. Raut.Hi Chetan,
You should use something like that:
Code Snippet
%windir%\ftp.exe -s:SCRIPT.TXT
Look at this link for additional details: http://www.ericphelps.com/batch/samples/ftp.script.txt
P.S. Note that this forum is about extending Visual Studio IDE - not about writing batch files.
Hope that helps, -
Execute batch file having gmake command
Hi, I am executing batch file having gmake command in it, when i run batch file directly it works correctly,
but when i try to execute it from LabVIEW using system Exec.vi
i got following error,
process_easy: DuplicateHandle(In) failed (e=6)
process_easy() failed to launch process (e=6)
Thanks in advanceWhat OS?
How are you calling it in LV?
What is in the batch file?
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps -
hi all
I want to know how to create batch file for
java program to execute with mouse click.open txt file
write these:
@echo off
@start java -classpath . *****
***** must be your main class name(dont add .class extension);
and change file extension to bat -
Interactive format IN BATCH FILE CALLING SQL QUERY
Hi,
Below code i have written to get some data from file test.txt and O/P the data from database. For this i m running MS-DOS batch file which is calling test.sql and which in turn calls the file test.sql and get desired result from database. The below script works perfectly
What i want is the more interactive format and not hard coded format esp location and name of the TEXT FILE . How i can make changes that whenever BATCH FILE is run, it ask for file name and location and then passes those information to SQL FILE which in turn fetches the results from database
BATCH FILE : test.bat
sqlplus sys/xxxxx as sysdba @test.sqlSQL FILE: test.sql
SET SERVEROUTPUT ON
DECLARE
lc_file_handle UTL_FILE.file_type;
lc_file_dir VARCHAR2 (100);
lc_file_name VARCHAR2 (50);
data VARCHAR2 (500);
v1 ECCSYS.hwcontainer.hwcontainerserialnumber%type;
v2 ECCSYS.storagedevice.devicename%type;
s2 ECCSYS.storagedevice.isreserved%type;
BEGIN
lc_file_dir := 'DATA_PUMP_DIR';
lc_file_name := 'test.txt';
lc_file_handle := UTL_FILE.fopen (lc_file_dir, lc_file_name, 'R');
LOOP
BEGIN
UTL_FILE.get_line (lc_file_handle, data);
v1 := SUBSTR (data,1,INSTR (data, ',', 1) - 1);
v2 := substr(data, INSTR (data, ',', 1, 1) + 1, length(data) - INSTR (data,',', 1, 1));
select isreserved into s2 from ECCSYS.storagedevice where devicename=v2 and storagearrayid = (select hwcontainerid from ECCSYS.hwcontainer where hwcontainerserialnumber =v1);
DBMS_OUTPUT.PUT_LINE(v1 ||' '|| v2 ||' '|| s2);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
EXIT;
END;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
UTL_FILE.fclose (lc_file_handle);
END;
EXIT;TEXT FILE : test.txt
000190300153,170
000190300153,171Hi,
I have made some changes in the batch and sql file but problem is , still test.sql is seeking name of the file even though its passed from batch file to sql file.
BATCH FILE : test.bat
@echo off
set /P id=Enter THE FILE NAME: %=%
echo %id%
sqlplus sys/xxxx as sysdba @test.sql %idSQL FILE : test.sql
SET SERVEROUTPUT ON
DECLARE
lc_file_handle UTL_FILE.file_type;
lc_file_dir VARCHAR2 (100);
lc_file_name VARCHAR2 (50);
data VARCHAR2 (500);
v1 ECCSYS.hwcontainer.hwcontainerserialnumber%type;
v2 ECCSYS.storagedevice.devicename%type;
s2 ECCSYS.storagedevice.isreserved%type;
BEGIN
lc_file_dir := 'DATA_PUMP_DIR';
lc_file_name := '&id';
lc_file_handle := UTL_FILE.fopen (lc_file_dir, lc_file_name, 'R');
LOOP
BEGIN
UTL_FILE.get_line (lc_file_handle, data);
v1 := SUBSTR (data,1,INSTR (data, ',', 1) - 1);
v2 := substr(data, INSTR (data, ',', 1, 1) + 1, length(data) - INSTR (data,',', 1, 1));
select isreserved into s2 from ECCSYS.storagedevice where devicename=v2 and storagearrayid = (select hwcontainerid from ECCSYS.hwcontainer where hwcontainerserialnumber =v1);
DBMS_OUTPUT.PUT_LINE(v1 ||' '|| v2 ||' '|| s2);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
EXIT;
END;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
UTL_FILE.fclose (lc_file_handle);
END;
EXIT; -
Creating text file from SQL with adding counter in Filename.
Hi,
I have a requirement for creating the Tesxt files from Oracle DB which i can achieve by ODISQLUNLOAD.
But tricky part is that i want have a file name+ counter such that Counter should start with 1 for the first file of the day, then 2,... and reset to 1 for every new date.
e.g. file0001, file0002,file0003,file0004,.... file0100 and so on for one day.
But when i will create a file on next day it should be created as again file0001, file0002,file0003,file0004,.... file0100 and so on.
I may be able to achieve this using some variables but unable to think how could i achieve this.
Any help would be appreciated.
Thanks and Regards,
MaheshHi Mahesh,
If the files are loaded as one batch process, for instance, by executing a single package, you could perform a looping function and store the counter as a variable. It would be very similar to the blog post here: https://blogs.oracle.com/dataintegration/entry/using_variables_in_odi_creatin - but you would be using the #counter variable in your filename. Each day that the package is run, the counter starts at 1.
Hope this will fit your needs.
Enjoy!
Michael R. -
Delete IFS file with sql command
Hi
Is it possible to remove a file from IFS using an sql command? If so, what is it?
Thanks
HugoNo, this is not possible, nor is it supported. You may use the Java API to delete a file.
-
Executing the batch file from SQL Server Agent job
Hi - I have a simple batch file (.bat) which connects the SFTP server and drop the files to location machine. When I run the .bat file manually its working fine but when I schedule it in SQL Agent its keep on running and never shows success message.
Could you please tell me how can i resolve it. Its very urgent for me.
thanksIf you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n) Remote working directory is /
When you connect via putty you get prompted to accept a key in interactive mode. At this point your batch file is waiting for someone to type in y or n.
Try running putty in batch mode to get around this.
http://the.earth.li/~sgtatham/putty/0.52/htmldoc/Chapter6.html#6.1.8
6.1.8 -batch: avoid interactive prompts
If you use the -batch option, PSFTP will never give an interactive prompt while establishing the connection. If the server's host key
is invalid, for example (see section 2.2), then the connection will simply be abandoned instead of asking you what to do next.
This may help PSFTP's behaviour when it is used in automated scripts: using -batch, if something goes wrong at connection time, the batch
job will fail rather than hang. -
Beginners tip: create new schema without SQL command
Hey, i know this sounds so beginner's, but can i create a new Schema in which I can create tabels and tables.. without using SQL commands, I mean from the GUI of Oracle 9i?
When I try to create any table under the new Schema (User) i keep on getting the
message: No Privellage on USERS namespace...this is why us old lags on so down on GUIs. Because they generate the SQL for you you will acquire no understanding of how the database really works. Honestly you would be better off reading the concepts guide and writing some raw SQL for yourself.
Cheers, APC -
RFBIBl00 - Creating Batch File
Hello Everyone,
I am writing a piece of ABAP code which creates a text file and submits
this via RFBIBl00. One of the amounts BBSEG-WRBTR is set to 166.44 and
this can be seen in the text file as 166.44.
However, when I run SM35 to process the batch file ( as in FB01) the amount is
being loaded onto the screen as 166,44 (notice the comma instead of the
decimal point).
Any ideas anyone????
Cheers
AndyHi Andy,
just to clarify, what happens is that in your input file, you specify the field value BBSEG-WRBTR as 166.44 but during the batch input run, it fills the screen field with 166,44?
Hm... not sure why that would happen, but is it possible that something is not right with the default settings of the user the BI session is executed with?
Does this happen with all fields that have decimals?
If you can not get rid of the problem, maybe you could run the BI with a user that has a comma as decimal notation in the user defaults and get the BI processing that way.
Maybe you are looking for
-
My SLD is configured in SOLMAN sys, How can I connect it with SAP PI system
Dear Friends My Basis has configured SLD in Solman, Now I cant use SXMB_IFR tcode in my PI that suggest me some error. saying "error in connection cant read secure connection config" or something like that. Plus SLDCHECK tcode is also not hap
-
Slow after installing yosemite
My Mac is slow after installing OS X Yosemite. Can anyone advise me as to anything I can do to speed up performance. I understand that I may need more HD and or Ram space but is there anything else I can do. Any apps that can guide me as to what is o
-
IPhoto will not open "version needs to be prepared"
New computer running Mt Lion iphoto version 9.4.2 message on attempted opening states: "To open your library with this verion of i photo it first needs to be prepared" Next message says this is not necessary if you are usiing version 5 or later. Thi
-
Interface GPIB with dc-ac inverter
I have built my own dc-ac inverter however I need to find out how to interface my inverter with LABVIEW so I can display the voltage and current and other power measurements
-
How to backout a VO substitution...
If after having uploaded the jpx file I need to remove the substitution, how is this accomplished? Do I use JDR_UTIL to delete the document with the substitution or do I remove the substitution from the jpx and upload it again?