Running oracle sql scripts by batch.
Hi. I need to run a batch of sql scripts. How do I do this using dos batch file.
Thanks.
Message was edited by:
Chael
in your createtable.sql you can spool the output
set serveroutput on
spool c:\yourspoolfile.txt
select statements....
spool off
exit
for more information you can checkt the sqlplus reference:
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14357/toc.htm
regards
Similar Messages
-
How to run a sql script in oracle forms
Hi,
For me there is an sql script. I need to run that sql script in forms.
Actually we will run that sql file in pl/sql developer by giving @and the file name.
But how to run that file in forms.
Can any one help on these.Which book I have to look.
ThanksActually there is a script files which will drop all the indexes and tables.
DROP querry will be there for each index and each table.
So I run the script all the indexes and all the tables will be deleted. So using forms I have to run that script.
Thanks -
Silent installation then run a sql script
I'm trying to do a silent install of 10g on a windows server.
I have created the response file and it works correctly.
After the oracle software has successfully installed I want to run some sql scripts on the newly created database, how do I do this automatically?
I have tried to create a batch script to do it but because the setup command opens in a separate window it never returns back to the batch script to run the sql.
install.bat:
start /wait c:\oracle_software\database\install_oraclesw.bat
call run_sqlscripts.bat
pause
install_oraclesw.bat:
setup -silent -responseFile c:\oracle_software\database\response\standard.rsp -nowait
Thanks in advanceI'm doing a 10gr1 silent install and one problem I ran into was the setup executes when cause java, then it closes, so the next step in my script executed immediately.
I had to use the choice command to bring up a prompt to pause the script.
start cmd /c setup.exe -responseFile c:\stardard.rsp -nowelcome -silent
choice /C YN /M "Press Y if install completes successufully, else press N." -
How can I run a SQL script file...
How can I run a SQL script file from a location on my computer without providing the whole path?
Is there some way I can set a "Working folder" in SQL Plus??
Thanks!
TomYou can create an environment variable called "SQLPATH" which is a list of directories that SQL*Plus will search for your .SQL
scripts.
I would like to use another directory than the oracle/bin...
How can I do this ??
Hello,
U can do this by this way:
Save odm_script.sql file to the default Oracle
directory i.e. Oracle-Home/bin and Run following command
through SQL Plus.
SQL>@Script_Name
I hope this will resolve ur problem.
Regards,
Omer Saeed Khan. -
Getting windows error during running the sql scripts from form 6i
I made a little form application. The purpose of this application is to generate explain plan for a particular SQL. Some sql scripts run internally in order to populate the result on forms screen after pressing the forms button but I am getting windows error during running the sql scripts from form 6i.
I am using forms 6i with patch 17 with Oracle 10G database on windows 2000 professional on same computer.
This application runs fine with 8i.
Please inform me where the problem is and how to overcome it.
Zafri.I am using Text_IO in my form's when button press trigger , inorder to create the
text file, then in the same when button press triger
I am calling RMAN via host command in order to run the script which was created by text_IO.
Below you find some of the code. I will appreciate if you solve the problem.
when button press trigger:
Declare
in_file3 Text_IO.File_Type;
linebuf3 VARCHAR2(1800);
output11 varchar2(1000);
BEGIN
output11:='C:\EXPLAIN_PLUS\misc\rm_file.bat ';
Host(output11,no_screen);
:sql.execution_plan:= 'Working........................';
synchronize;
in_file3 := Text_IO.Fopen('c:\explain_plus\misc\create_table.txt', 'w');
Text_IO.Put_Line(in_file3, linebuf3);
Text_IO.put_line(in_file3,' ');
Text_IO.put_line(in_file3,' run { sql "create table PLAN_TABLE (statement_id,...object_name varchar2(30),object_instance numeric,object_type varchar2(30),optimizer varchar2(255),search_columns number,id .....partition_start varchar2(255),partition_stop varchar2(255),partition_id numeric,other long,distribution varchar2(30)) "; } ');
Text_IO.put_line(in_file3,' ');
Text_IO.put_line(in_file3,' ');
Text_IO.FCLOSE(in_file3)
Declare
un VARCHAR2(80);
pw VARCHAR2(80);
cn VARCHAR2(80);
output VARCHAR2(1000);
output2 VARCHAR2(1000);
dummy varchar2(40);
in_file Text_IO.File_Type;
linebuf VARCHAR2(1800);
BEGIN
Get_Connect_Info(un,pw,cn);
/* for Plan_table Begg. Second INNER BLOCK */
declare
dummy2 varchar2(40);
begin
select table_name into dummy2 from all_tables where table_name='PLAN_TABLE';
if dummy2 = 'PLAN_TABLE' then
output2:='rman target/ nocatalog @C:\EXPLAIN_PLUS\MISC\TRUNC2.txt ' ;
Host(output2,no_screen);
end if;
exception
when no_data_found then
output2:='rman target/ nocatalog @C:\EXPLAIN_PLUS\misc\create_table.txt ';
Host(output2,no_screen);
end; -- -
Running a SQL Script to Create an Object Type
When I do Database Development with JDeveloper and fellow the instruction at
http://www.oracle.com/technology/obe/obe1013jdev/dbdevelopment/obe_%20dbasedevmt.htm
and try to Running a SQL Script to Create an Object Type by Right-clicking emp_rec.sql in the editor and
choose Run in SQL*Plus > hrconn, the new Obuect type can not created. The screen flashs and I only got the
message
"Invoking SQL*Plus...
D:\oracle\product\10.2.0\db_1\BIN\cemutls.exe
hr@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SID=ORCL)))
@emp_rec.sql" and nothing else (No error like JBO-XXXXX).
Can anybody Help Me? Thanks a lot!
SID: ORCLHi Simon,
Having had a closer look at your original message it seems that rather than selecting the SQL*Plus executable in the directory you have managed to select the file 'D:\oracle\product\10.2.0\db_1\BIN\cemutls.exe'.
If you go to 'Tools | Preferences' and select the 'Database Connections' node and alter the 'SQL*Plus Executable' field to 'D:\oracle\product\10.2.0\db_1\BIN\sqlplus.exe' and then try again, this should then work.
Regards,
Lisa -
Hi everybody,
I installed AWM 11.1.0.7B and Oracle Database 11g software, version 11.1.0.6.0.
I am trying to install Sample Schemas & Code.
I got an error running global_11g_create_cubes.sql script that I downloaded from the http://www.oracle.com/technology/products/bi/olap/olap_downloads.html#software
Here is an error:
Begin installation
... deleting GLOBAL AW (if it exists)
... creating GLOBAL AW
begin
ERROR at line 1:
ORA-37162: OLAP error
XOQ-00506: Unable to parse XML string sent from the client to the server
ORA-06512: at "SYS.DBMS_CUBE", line 88
ORA-06512: at "SYS.DBMS_CUBE", line 134
ORA-06512: at "SYS.DBMS_CUBE", line 154
ORA-06512: at "SYS.DBMS_CUBE", line 144
ORA-06512: at "SYS.DBMS_CUBE", line 181
ORA-06512: at line 2
The following line in the script gives an error:
dbms_cube.import_xml('GLOBAL_INSTALL', 'GLOBAL_MV.XML');
Any help will be greatly appretiated.
Thank you.
- tI suspect the problem is that you are using an 11.1.0.7 client to access an 11.1.0.6 server. This configuration should work, but there was a bug at some point with new clients and old servers. In any case you would be advised to upgrade your server to either 11.1.0.7 or, at least, the latest 11.1.0.6 OLAP patch.
-
Error 45 Initializing In SQL*Plus When Running A Sql Script
Hi All
I have a daily scheduled jobs running on Windows server 2003 and 2008. Oracle Version :10.2.0.1 and 10.2.0.4
right now jobs are not even starting when i run them manually. Found the error Error 45 Initializing In SQL*Plus When Running A Sql Script.
it says Bug:3039738.
what is the solution to fix this Bug ?
thanks
Shawnuser9174724 wrote:
Hi
do you think the Problem is not with the script ?
when i run the job its reaching SQLPLUS and giving error
Error 45 Initializing In SQL*Plus When Running A Sql Script .
Server:windows 2003 and oracle version :10.2.0.1
CMD /C %ORACLE_HOME_PRIME%\bin\sqlplus.exe /NOLOG @ %xxxx_HOME%\DBA_Backup\BackupDo.sql testdb BackupFull
The above line does the following:
1) launches a command procesor
2) passes that command processor the following command line parms:
/C
(process the following command, then terminate)
%ORACLE_HOME_PRIME%\bin\sqlplus.exe
the launched processor will process the executable 'sqlplus.exe' found in the \bin subdirectory, found in the directory indicated by the environment variable ' ORACLE_HOME_PRIME'. The remainder of the command line will be passed to sqlplus.exe for interpretation and processing
/NOLOG
tell sqlplus to start up without trying to immediately log on to a database
typically used to indicate to sqlplus that the immediately following string names a file of sql and sqlplus commands to be processed.
%xxxx_HOME%\DBA_Backup\BackupDo.sql
tell sqlplus to execute the commands found in the file 'BackupDo.sql', found in the subdirectory DBA_Backup, found in the directory name by the environment variable 'xxxx_HOME'.
testdb
BackupFull
pass the values 'testdb' and 'BackupFull' to be used as values for substitution variables &1 and &2 in the file 'BackupDo.sql'
Script:
rmanbackup.rman
BACKUP AS COMPRESSED BACKUPSET DATABASE FORCE PLUS ARCHIVELOG;
DELETE NOPROMPT ARCHIVELOG ALL BACKED UP 2 TIMES TO DEVICE TYPE DISK;
LIST BACKUP SUMMARY;
LIST BACKUP;
EXIT;I don't know what you expect of this. It is an rman script and we've seen no sign of an rman script being executed in any of what you've shown us. RMAN commands are processed by rman, not sqlplus.
Unfortunately, you didn't think showing us the contents of BackupDo.sql was of any value in finding out what your problem was.
Edited by: EdStevens on Jul 11, 2011 7:58 PM -
Send mails with csv file as an attachment through oracle(SQL SCripts / Stor
Hello Everybody,
I have recently come across a requirement in which I am supposed to send mails with csv file as an attachment through oracle(SQL SCripts / Stored Procedure) .
The contents of the csv file are to be retreived from the Database as well as the content of the mail and to whom it needs to be sent has also to be picked up from the database.
Can somebody suggest me with a suitable code for the same?
Would be of great help..!!
Thanks & Regards,
- VR
Edited by: user646716 on Dec 18, 2009 10:44 AMread below links
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:255615160805
http://www.orafaq.com/wiki/Send_mail_from_PL/SQL#Send_mail_with_UTL_TCP_-withattachments
How to send csv file as an attachment -
How to run the SQL Script in SQL Prompt?
Hi ExpertGroup,
I have written one SQL Script name called "MySQLSCript.SQL". I want to know how to run the SQL Script in SQL Prompt?.
Generally, I run SQL Script in PL/SQL Developer tool. But In this case, some SET command is not working/supporting in PL/SQL Developer Tool.
Let me know, How to Run in SQl Prompt.
Thanks & Regards,
Senthil K Kumar.This is my SQL Script....
SET COLSEP '|'
SET LINESIZE 32767
SET PAGESIZE 50000
/* SET LINESIZE 3000
SET PAGESIZE 50000
SET DEFINE OFF */
SET ECHO OFF
SET FEEDBACK OFF
--SET HEADING OFF
SET TRIMSPOOL ON
SET NEWPAGE NONE
SET UNDERLINE OFF
SPOOL &&EnterPath;
SELECT * FROM &&TableName;
SPOOL OFF
SET FEEDBACK ON
--SET DEFINE ON
PROMPT Done.
I am able to run this script in SQL Prompt....
Its executing fine...
But, If I am executing again it maynot asking for new set of data....
alternativily its taking old values only.....
how can i exeute with new set of data in the sql prompt..... -
How and where to run utlxplan.sql script?
Hi,
A basic question: where and how to run utlxplan.sql script? I'd like to know both in window and linux environment.
regards.....From sqlplus, you can connect as sys and run the utlxplan.sql. Then you need to grant privileges to other users and create synonyms...
-
How to run sql scripts using batch file for a web dynpro data dictionary
Hi,
I want to develop a sql script to be executed on the server alongwith the installation of a product to pre-populate web dynpro data dictionary tables required for the application.
I further require to make the scripts independent of the database name,so that it can be run at any client environment.
Your help will be appreciated and rewarded.See shoblock's answer
call sql script from unix
masterfile.sql:
@file1 &1
@file2 &2
@file3 &3
@file4 &4
then just call the master script:
sqlplus userid/password @masterfile <p1> <p2> <p3> <p4> -
How can I convert a mysql sql script to a oracle sql script
Hi,
We have a bunch of tables with data running on a mysql server.
This should now be moved to an oracle 9 db.
are there any tools to convert the import script of a mysql db
to a format of the sql script that work for oracle ?
Thanks
MichaelOracle has a tool called Migration Toolbench, which supports MySQL 3.22 and 3.23:
http://otn.oracle.com/tech/migration/workbench/content.html
On this same topic, I was wondering if anybody has tried migrating from PostgreSQL to Oracle 9i. The workbench doesn't seem to support it, and feeding a pg_dump file directly into SQL*Plus is not working. -
How to use parameters in oracle SQL script????
Right now I am writing a SQL script to create a schema and build the objects of this schema....
I use a .net winform program to run sqlplus to parse this sql script ...
The problem is that the schema name and the tablespace's location and the sys password must be input by the user, so my SQL script should use these runtime input parameters instead of const parameters....
So, how to use parameter in SQL script ...........
Are there some example scripts in oracle home directory for me to refer to????Hi,
UNISTD wrote:
thanks .....
what's the difference between variable , define, accept in sqlplus ???VARIABLE declares (but does not assign a value to) a bind variable. Unlike substitution variables, bind variables are passed to the back end to be compiled, and they can only be values in certain data types. You can not use a bind vaiable in place of an identifier, so to do something like
CREATE USER &1 ...a bind variable won't work.
"DEFINE x = y" sets the substitution variable &x to have the value y. There is no user interaction (unless x or y happen to contain undefined substtiution variables).
"DEFINE x" shiows the value of the substitution variable &x, or, if it is undefined, raises a SQL*Plus error. I use this feature below.
ACCEPT sets a substitution variable with user interaction.
And if the user miss some parameters in “sqlplus /nolog ssss.sql par1 par2 par5 par6”, how to use default value of the miss parameters??Don't you need a @ befiore the script name, e.g.
sqlplus /nolog @ssss.sql par1 par2 par5 par6Sorry, I don't know of any good way to use default values.
The foloowing works, but, as you can see, it's ugly.
"DEFINE 1" display a message like
DEFINE 1 = "par1" (CHAR)if &1 is defined; otherwise,it will display a SQL*Plus error message like
SP2-035: symbol 1 is UNDEFINEDNotice that the former contains an '=' sign, but the latter does not.
The best way I know to use default values is to run the DEFINE command, save the output to a filee, read the file, and see if it's an error message or not.
So you can use a script like this:
-- This is DEFINE_DEFAULT.SQL
SPOOL got_define_txt.sql
DEFINE &dd_old
SPOOL OFF
COLUMN dd_new_col NEW_VALUE &dd_new
WITH got_define_txt AS
SELECT q'[
@got_define_txt
]' AS define_txt
FROM dual
SELECT CASE
WHEN define_txt LIKE '%=%'
THEN REGEXP_REPLACE ( define_txt
, '.+"
([^"]*)
, '\1'
ELSE '&dd_default'
END AS dd_new_col
FROM got_define_txt
{code}
and start your real script, ssss.sql, something like this:
{code}
DEFINE dd_new = sv1
DEFINE dd_old = 1
DEFINE dd_default = FOO
@DEFINE_DEFAULT
DEFINE dd_new = sv2
DEFINE dd_old = 2
DEFINE dd_default = "Testing spaces in value"
@DEFINE_DEFAULT
{code}
when this finishes running, the substitution variable &sv1 will either have the value you passed in &1 or, if you didn't pass anything, the default value you specified, that is FOO.
Likewise, &sw2 will have the value you passed, or, if you didn't pass anything, the 23-character string 'Testing spaces in value'.
Here's how it works:
Define_default.sql puts the output of the "DEFINE x" command into a column, define_txt, in a query. That query displays either the existing value of the substitution variable indicated by &dd_old or, if it is undefined, the default value you want to use, which is stored in the substitution variable &dd_default. The substitution variable named in &dd_new is always set to something, but that something may be its existing value.
Notice that the paramerters to define_default.sql must be passed as global varibales.
Why didn't I just use arguments, so that we could simply say:
{code}
@DEFINE_DEFAULT sv1 1 FOO
{code}
? Because that would set the substitution variables &1, &2 and &3, which are miost likely the very ones in which you're interested.
I repeat: there must be a better way, but I'm sorry, I don't know what it is.
I usually don't do the method above. Instead, I always pass the required number of parameters, but I pass dummy or plce-holder values.
For example, if I wanted to call ssss.sql, but use defulat vlaues for &1 and &3, then I would say something like:
{code}
@ssss ? par2 ?
{code}
and, inside ssss.sql, test to see if the values are the place holder '?', and, if so, replace them with some real default value. The use has to remember what the special place holder-value is, but does not need to know anything more, and only ssss.sql itself needs to change if the default values change. -
Oracle SQL Script in Installshield
Hello,
I know this isn't the Installshield forum, but I haven't gotten a response there yet, so I figured I'd ask here. I have a script that needs to be run during install to create a schema for our product to store data in. The script runs flawlessly when copied and pasted into i*SQL, but fails when run through the installer. Not only does it fail, I'm at a loss to describe the errors. I've attached the script, but I'll type out the first couple lines to illustrate my point.
Original script's first 2 lines:
CREATE USER xxxxxxx IDENTIFIED BY xxxx;
GRANT CONNECT TO xxxxxxxx;
I had to remove the semicolon from the first line to even get that to run. The second line won't run at all. With the semicolons, I get '911 - invalid character' errors, without them, I get '922 - Missing/Invalid option'.
Is there anything special I should know about running Oracle scripts through Install Shield that you could shed some light on? I'd be very appreciative for any help or ideas, as the deadline is approaching and this is beyond maddening at this point.Just an idea but can you execute the whole process as an anonymous block?, like:
begin
execute immediate 'CREATE USER xxxxxxx IDENTIFIED BY xxxx';
execute immediate 'GRANT CONNECT TO xxxxxxxx';
end;
/
Maybe you are looking for
-
Iphone getting a certificate error logging into Lync 2013
Hello, I am having a strange issue with Lync Mobility. Android seems to work just fine, but my IPhone clients are throwing certificate errors. Everything is showing up properly in the Lync Connectivity Analyzer. The LyncDiscover URL seems to work jus
-
Round trip export/import from Mac OSX iCal
Since there isn't an iSync plug-in for Oracle Calendar (yet?) I thought I'd try a round-trip import/export between Oracle Calendar and Mac OSX iCal. Inconvenient, but it should would because the UIDs in the .ics file would be the same and an import w
-
KeyEvent.consume() doesn't work
I have JFormattedTextField subclassed and implement a KeyListener to avoid typing invalid characters. so i implemented: * Implements KeyListener. public void keyPressed(KeyEvent event) { System.out.println("keyPressed: "+event);
-
Downconvert firls from LV8.6 to LV7.1
Hi everyone, can someone please convert the function FIRLS (Labview version 8.6 (found on this site)) down to LabView version 7.1? I know, there is a solution using the MathScript but I hope there's a way without an Matlab installation. Greetings Tha
-
How to import songs into iTunes?
I had started to add the contents of my external hard drive to itunes a process which for some reason got interrupted. I want to import the remaining contents but cannot figure out how to do so without duplicating what I have already done as I cannot