How to execute one sql file in unix

Hi,
I need to run the follwing script in a file in unix , then run the corresponding spooled file again
SET echo OFF;
SET sqlblanklines ON;
SET feedback OFF;
SET linesize 1500;
SET trimspool ON;
SET termout OFF;
SET pagesize 0;
spool updatedfix.sql;
SELECT ' <update stmt>
spool OFF;
SET termout ON;
SET echo ON;
SET feedback ON;
How can the above script in a file be executed in unix
like
ed script
@ script
then
@ updatedfix.sql;
plz help
thanks

I haven't got unix to hand but the principle is the same in windows batch files..
c:\temp>type gen_update.sql
set echo off
set sqlblanklines on
set feedback off
set linesize 1500
set trimspool on
set termout off
set pagesize 0
spool updatedfix.sql
select 'update emp set comm = -1 where comm is null;' from dual;
select 'exit' from dual;
spool off;
set termout on
set echo on
set feedback on
exit
c:\temp>sqlplus user/pass@db @gen_update.sql
SQL*Plus: Release 10.2.0.3.0 - Production on Wed May 6 12:25:10 2009
Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> set feedback on
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
c:\temp>sqlplus user/pass@db @updatedfix.sql
SQL*Plus: Release 10.2.0.3.0 - Production on Wed May 6 12:25:37 2009
Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
10 rows updated.
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
c:\temp>Just run one after the other in the script file.

Similar Messages

  • How to execute a  .sql file from a batch file

    Hi all
    I've to take backup of a database weekly twice on every wednesday & Friday @ 5pm IST. I've written a hot backup script, which works every well.
    now i want to automate the script. ie i want this script to run on wednesday & friday @ 5pm without any human interfearance ie with out actually any1 executing this script.
    i created a batch file prod.bak with the following lines
    @echo off
    set oracle_sid=testdb
    set oracle_home=d:\oracle\ora92
    sqlplus /nolog
    connect sys as sysdba/oracletest@testdb
    this batch file when eexecuted connects me to sql prompt.
    Now i want to execute my backup script bkp.sql automatically when it is connected to sql prompt.
    (i tried with these lines in the above batch file...
    call bkp.sql---it just opens the bkp.sql file in notepad & displays the script
    start bkp.sql---same as call
    connect / as sysdba/pwd@[email protected] --- does not work simply remains a the sql prompt.
    At 17:00 /Every:w,f "d:\bkp.sql"---does not work simply remains at the sql promt.)
    Can any1 let me know what should i write in the batch file that will execute the bkp.sql file automatically after it gets connected to sql prompt. M using oracle 9i.
    I'll manage he time through windows utility of scheduling task.. Let me know how to execute the .sql file from a batch file.
    Thanks
    Tripti

    Try
    sqlplus "sys/oracletest as sysdba" @bpk.sql
    Working locally, and having set the ORACLE_SID, you don't need to specify the SqlNet alias (@testdb).
    Remember to put an exit at the end of the bpk.sql script.

  • How to execute one .exe file with as3 in air ?

    Hi
    How to execute one .exe file with as3 in air?
    I want do this work without fscommand .
    plize help me .

    itsdhanasaraa wrote:
    But as this a web application ... By using Runtime i'm getting some probs ..
    Let me guess, you want your web application to run a program on the client and to your surprise that's not working?
    Ain't gonna happen.
    its taking more time to execute .... that's y is there any other option to execute .exe file other than Runtime.getRuntime().exec("filename");Write proper English and you may be taken more seriously.
    1) it's not "taking more time to execute", whatever that's supposed to mean.
    2) there's no other way to execute something. Not that you should every use even that way anyway
    3) whenever you start thinking of executing external programs from Java, start thinking of not using Java in the first place.

  • How to execute a sql file inside a plsql file?

    It's easy to exec a plsql inside a sql. Simply
    start my_proc.plsql
    exec my_proc;
    But how to execute a sql file inside a plsql file?
    declare ...
    begin
    start my_sql.sql?
    end;
    Thanks.
    - Zac

    Doesn't work. Even though @ is different from start in this case but it just doesn't like the way sql and plsql are mixed. For example:
    DECLARE n NUMBER := 0;
    BEGIN
    select COUNT(*) INTO n from user_tab_partitions;
    DBMS_OUTPUT.put_line('Number of partitioned tables = ' || to_char(n));
    if n = 0 then
    DBMS_OUTPUT.put_line('createViewsProcs.sql');
    @createViewsProcs.sql
    else
    DBMS_OUTPUT.put_line('createPartitionViewsProcs.sql');
    @createPartitionViewsProcs.sql
    end of;
    END;
    SQL> @postimp.sql
    SQL> DECLARE n NUMBER := 0;
    2 BEGIN
    3 select COUNT(*) INTO n from user_tab_partitions;
    4
    5 DBMS_OUTPUT.put_line('Number of partitioned tables = ' || to_char(n));
    6
    7 if n = 0 then
    8 DBMS_OUTPUT.put_line('createViewsProcs.sql');
    9 @createViewsProcs.sql
    9 SET SERVEROUTPUT ON SIZE UNLIMITED;
    10 SET TERM ON;
    11 SET ECHO ON;
    12 EXEC DBMS_OUTPUT.put_line('STARTING VIEWS, PROCS, ETC, THIS MAY TAKE A FEW MINUTES');
    13 EXEC DBMS_OUTPUT.put_line(SYSTIMESTAMP());
    14
    15
    16 CREATE OR REPLACE PACKAGE db_convert AS
    17 FUNCTION ......
    32 END;
    33 /
    SET SERVEROUTPUT ON SIZE UNLIMITED;
    ERROR at line 9:
    ORA-06550: line 9, column 5:
    PL/SQL: ORA-00922: missing or invalid option
    ...

  • How to execute a SQL procedure in UNIX

    How to execute a SQL procedure in UNIX

    Check this out..
    -Sri
    << a.sql >>
    create or replace procedure junk(nout out varchar2) is
            x varchar2(20);
    begin
            select 'Sam' into x
            from dual;
            nout := x;
    end;
    << Shell script >>
    sqlplus -s / << DOC
    scott/tiger
    variable x varchar2(20);
    set autoprint on
    @a.sql
    begin
    junk(:x);
    end;
    exit
    DOC
    << Execution of Shell SCript >>
    # sh b.sh
    Procedure created.
    PL/SQL procedure successfully completed.
    X
    Sam

  • How to call one .sql file from other .sql

    I am trying to call no of .sql files from one .sql file.
    But it gives me error in SQL*PLUS that unable to open file.
    Suggest me solution.
    Thanks
    Chanda

    Are the sql files in the current directories where sqlplus has been started ?
    If not, did you give the full path name for the called sql files when calling them from sqlplus ?
    Could you give us the complete sqlplus command that you use to call your files and the physical location of the called files with the exact error message ?

  • How to execute one java file in another java file

    Hi All!
    I hava a problem.. I need to validate functionality of one java file in my Junit test case.. so, I need to run that java file in my test file..
    How should I start with???? Are there any java API's for that.. I checked 'system' ..but which function will suite that functionality,,I am not sure about..

    I need to check the functionality of deletetion which
    is done by a java class.. Now I need to check this
    functionality..whether it is deleting or not... in my
    test case.. so, for that I need to execute that java
    file in similar manner as how we normally do it...,
    in my test case..So let the test case create a file and have your class delete it. What's there to run?

  • Any ideas how to execute a .sql file on database server from java?

    Any ideas how to execute a xyz.sql file (which is fisically on
    database server) from java?
    thanks

    Try
    sqlplus "sys/oracletest as sysdba" @bpk.sql
    Working locally, and having set the ORACLE_SID, you don't need to specify the SqlNet alias (@testdb).
    Remember to put an exit at the end of the bpk.sql script.

  • How to execute PL/SQL file (*.sql) ?

    In SQL*plus, I use edit command to input a sample PL/SQL program into a foo.sql, but now I don't know how to execute this PL/SQL file in SQL*plus. Who can help me ?

    In sql plus, issue the following command (for purposes of this example, I am assuming that foo.sql is in the c:\temp directory.
    @c:\temp\foo.sql
    The "@" can also be written as
    start c:\temp\foo.sql

  • How to Run a .sql file from simple java class

    How to execute a .sql file consisting of Complex Queries,procedures through simple java class.
    The queries may have different delimiters,queries independant of each other.
    I am able to do with Specific De-limiter.But I need in such a way that there should not be any
    Constraints. Since My .sql may Contain different De-limiters.
    If any one can Suggest Some Solution.
    It will be Great Help.
    regards
    Anil

    Check out ibatis script runner, it' a third party library but quite handy for running sql files...
    m

  • How to open multiple sql files in only one ssms instance

    how to open multiple sql files in only one ssms instance, I can't get anything to work that I find online..I hope you can help us.

    I tried opening two files but selecting and hitting enter. it opens one SSMS and two tabs.
    Balmukund Lakhani
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    | Facebook
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • Executing multipule .sql files in Sequence

    Hi ,
    I am new to oracle world . I need to execute 150 .sql files from my local machine . I am trying do something like this ...
    but facing many errors ... I am using oracle 10 g
    Please advice me .
    CREATE OR REPLACE PROCEDURE MYPROC AS
    BEGIN
    DECLARE
    CNT NUMBER :=0;
         @c:\sql\1.sql;
    CNT:=CNT+1;
    @c:\sql\2.sql;
         CNT:=CNT+1;
         commit;
    EXCEPTION
    BEGIN
         ROLLBACK;
         DBMS_OUTPUT.PUT_LINE('TRANSACTION ROLLEDBACK')
         DBMS_OUTPUT.PUT_LINE('Failed at Executing' CNT-1)
    CNT:=0;
    END;
    END;
    END MYPROC

    user11791474 wrote:
    i need to create pl sql because if any of these files are errored then i need to terminate my execution . I guess just executing 15o sql files in one wrapper sql will keep executing next sql files.
    do you have any idea about how to call sql files in pl sql then ?No you can't call an sql*plus file in Pl/sql.
    What you can do in SQl*plus is someting like this:
    untested
    -- set an exit condition
    WHENEVER SQLERROR EXIT ROLLBACK
    spool logscripts.log
    prompt "running script 1"
    @script1.sql
    prompt "running script 2"
    @script2.sql
    prompt "running script 3"
    @script3.sql
    prompt "running script 5"
    @script4.sql
    prompt "running script 6"
    @script5.sql
    spool off

  • How to execute PL/SQL from Java?

    I want to execute (compile) a PL/SQL file to a database and I don't know how it can be done with Java.
    Please note that I am NOT trying to call a stored procedure. I know that can be done with CallableStatement.
    Background:
    My actual requirement is to execute PL/SQL files with error notifications. I tried Ant SQL task; but it fails to give compilation error information. I also tried another open source task called Incanto - that also not that helpful as if I execute in bulk, very hard to figureout which one throws error. Hence I decided to write my own Ant task.

    Hi,
    do u want to execute PL/SQL files? or just you want to execute the block of code?
    in the case of PL/SQL file:
    you need to read total file as StringBuffer/String and then execute.
    Block of code:
    you can directly pass the code to the java file as input and then execute.
    Ex:
                   StringBuffer queryString = new StringBuffer();
                    queryString = queryString.append("BEGIN execute immediate ' ");
              queryString = queryString.append(query);
              //queryString = queryString.append("BEGIN dbms_job.run(142);END;");
              queryString = queryString.append(" '; END; ");
              final_Query = queryString.toString();
              try {
                   System.out.println("final :   "+final_Query);
                   cstmt = con.prepareCall(final_Query);
                   System.out.println("Job is Running...");
                   new ThreadCountdownExtThread().start();
                   System.out.println("bfore execute()...............");
                   cstmt.execute();Note: if you are running pl/sql file read file and save it in a Stirng , and then do the same as above stated

  • How to run a JAR file in Unix system?

    hi there
    ca anyone tell me how to run a JAR file in unix system or X window, thank you

    You want to create an executable JAR file? You do it in the following way.
    Create a manifest file such as manif.txt and the contents should contain
    Main-Class: foo
    assuming foo is the name of your main class. Then create the jar as follows
    jar cvfm foo.jar manif.txt foo.class
    I hope that helps you!
    you can find more info here http://java.sun.com/docs/books/tutorial/jar/

  • How to execute a sql script in dbms_job?

    how to execute a sql script in dbms_job?

    See my response to Re: how to execute a sql script file in procedure or trigger.
    Cheers, APC

Maybe you are looking for

  • Purchase Order and Invoice creation

    Hi All, I am having some fields related to Purchase order and Invoice creation, i have to find out the tables to which tables these fields belongs to. Below are the Header fields: Wrbtr  Tcode - MIRO, Lfsnr   Tcode - MIGO, Evertn Tcode - Me32k, Kbetr

  • How do I write an OutputStream to a String?

    I'm using an ObjectOutputStream to serialize a LinkedList. I tried using a ByteArrayOutputStream and invoking the toString() method thereof, but it changes the first two entries in the array and throws off the readObject() method of the ObjectInputSt

  • Laptop Crashed During Maverick Install -- Need Help

    Hello Everyone, Before we get started, I just want to open with this info: My Macbook Pro is from 2008, and has a notorious habit of crashing... I hear what sounds like a rhythmic "ticking" sound from within the laptop, and everything on screen freez

  • Sharing printer

    I have found many questions similar to mine amongst the discussions, but nothing seems to match my situation exactly, so I've decided to describe my problem as a new topic. I am trying to print on a Lexmark X5250 from my iBook (running 10.3.9) wirele

  • Modify a Script To Not Run at Shutdown?

    Using the archstats script listed below, how could I alter the script so that it only runs the $ARCHSTATS_CMD command during boot but not when shutting down? I see that is handled by the 'stop)' section, but I am unclear how to properly remove this p