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.

Similar Messages

  • Using 10g SQL Plus from a batch file

    I installed the Oracle Database 10g Express Client and configured my ODBC and tnsnames.ora settings, and I think I have it all right, because when I open the SQL Command Line I can connect to the database just fine using:
    connect <username>/<password>@<database>
    However, when I try to log in through a non-SQL command line or batch file using the syntax:
    sqlplus <username>/<password>@<database>
    I get the error "ORA-12154: TNS:could not resolve the connect identifier specified." That syntax used to work for me with 9.2. Does the functionality still exist in 10.2?
    Update #1:
    The sqlplus login works from a normal command widow if I first CD C:\XEClient\bin. I still can't get it to work from a batch file, even when I specify the path. Does this mean the batch file command can't find my tnsnames.ora? If so, what environment variable do I need to set? I already have the client directory in the Path and ORACLE_HOME variables.
    Update #2:
    I started randomly trying every Oracle environment variable I could find a reference to, and found that setting TNS_ADMIN to the C:\XEClient\bin directory worked.
    I don't need any responses to this post, so it can be deleted by an admin.
    Edited by: user11241849 on Jan 13, 2010 12:05 PM

    Hi Toni,
    It is my first post here and I though telepathy already operated here :)
    it is Oracle 9 I am talking about.
    actually, I have 2 batch files
    File 1, lets say the file name is batch1.bat and the contents are
    sqlldr user/pwd@tnsname control='Control.ctl'  data='data.txt'
    File 2, batch2.bat and the contents are
    Batch1.bat
    Sqlplus user/pwd@tnsname @callproc.sql
    Now if I run Batch2.bat, then only the first line to be executed which calling the batch1.bat , the second line (sqlplus) never executed!
    Best Regards,
    Yousef
    Edited by: yousef_bayyari on 10-Nov-2009 06:25

  • How to execute pl/sql block from a file

    hi all,
    can anybody tell me how to execute a pl/sql block from a file.it wont contain any procedures.it is of the form
    --begin
    --declare
    --end;
    Thanx

    Here is the file
    File is stored in C Drive (Windows Environment)
    declare
    x number;
    begin
    select 1 into x from dual;
    dbms_output.put_line(x);
    end;
    SQL> @c:\t.sql;
    1
    PL/SQL procedure successfully completed.Are you facing any issues?
    Regards,
    Bhushan

  • How to check Oracle DB Status from Windows batch file

    Hi,
    I need a script which can be used to check the Oracle Database Status from windows command batch file.
    Thanks,
    Kishore

    Hi Virendra,
    I have followed the steps mentioned in ur reply, But couldn't get the output.
    I am getting the below error
    C:\>db_utility.bat PLPDEV
    ERROR:
    ORA-12560: TNS:protocol adapter error
    SP2-0306: Invalid option.
    Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
    where <logon> ::= <username>[<password>][@<connect_string>] | /
    SP2-0306: Invalid option.
    Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
    where <logon> ::= <username>[<password>][@<connect_string>] | /
    SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
    C:\>
    Below is my bat file
    @echo off
    set ORACLE_SID=%1
    echo sys/ltd1_plp as sysdba
    echo set cmdsep on
    echo set cmdsep '"'; --"
    echo set term on
    echo "select status from v$instance;"
    ) | sqlplus -s
    Thanks

  • HOW TO: Open SQL Developer from a batch file with specific tables opened

    I use SQL Developer daily as I develop database intensive programs.
    ** Question **
    How can I define a specific configuration of tabs (i.e. tables, procedures, etc) to be opened upon startup of SQL Developer?
    For example, creating a .BAT file to open SQL Developer with a specific set of table tabs already opened. This will save me the time every morning I use to open SQL Developer and configure all the tables I need opened.
    NOTE: I have tried various options of appending a table name to a command line starting sqldeveloper.exe. For example: ..\sqldeveloper.exe mydatabase.mytable. However, this only opens a worksheet tab with the name "mydatabase.mytable" but does not open my actual table.
    Any help will be appreciated.
    - Gary Davis

    what version are you using? Sql Dev 1.5?
    Not an exact answer, but you could try using Table FILTER
    click on your connection
    right button on TABLES
    click apply filter
    as for your question, check out:
    Re: EA1 - Automatically open connection list at startup?
    or
    SQL Developer

  • 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
    ...

  • SQL Loader-How to insert -ve & date values from flat text file into coloumn

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide.

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide. Try something like
    someDate    DATE 'DDMMYYYY'
    someNumber1      "TO_NUMBER ('s99999999.00')"
    someNumber2      "TO_NUMBER ('99999999.00s')"Good luck,
    Eric Kamradt

  • How execute pl/sql command from Oracle ADF Business Components

    can't find examples for how execute pl/sql command from Oracle ADF Business Components and how call pl/sql package procedure from ADF Business Components.
    insert,update,delete rows in view object instance cache is good but if i must do some complex operations while insert,update,delete rows..it's more better for me to call
    pl/sql procedure from oracle db.Am i wrong ????

    Roman,
    this should be similar to how it worked in JDeveloper 9.0.3. hava a look at <JDev903 Home>\BC4J\samples\StoredProc for a code example.
    Frank

  • How to load SQL scripts from a text file.

    Hi, i tried several time to load a text file/SQL script with 10 different tables and data, but 10g Express doesen't allows me to do that, any one can direct me or point out to me what i should do or do i need to adopt any special method to to get this done. i am sure there must be some thing where you can upload SQL scripts from a text file (in SQL command editor!). thanks

    Hi,
    see my other answer here:
    SQL command editor doesn't take more than 1 insert command
    This seems to be a duplicate question, right? Or am I missing something?
    Regards,
    ~Dietmar.

  • 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

  • How to execute an SQL query present in a string inside an ABAP program?

    hello,
    How to execute an SQL query present in a string inside an ABAP program

    Raut,
    You can execute Native SQl statements.
    Ex: To use a Native SQL statement, you must precede it with the EXEC SQL statement, and follow it with the ENDEXEC statement as follows:
    EXEC SQL [PERFORMING <form>].
      <Native SQL statement>
    ENDEXEC.
    There is no period after Native SQL statements. Furthermore, using inverted commas (") or an asterisk (*) at the beginning of a line in a native SQL statement does not introduce a comment as it would in normal ABAP syntax. You need to know whether table and field names are case-sensitive in your chosen database.
    In Native SQL statements, the data is transported between the database table and the ABAP program using host variables. These are declared in the ABAP program, and preceded in the Native SQL statement by a colon (:). You can use elementary structures as host variables. Exceptionally, structures in an INTO clause are treated as though all of their fields were listed individually.
    If the selection in a Native SQL SELECT statement is a table, you can pass it to ABAP line by line using the PERFORMING addition. The program calls a subroutine <form> for each line read. You can process the data further within the subroutine.
    As in Open SQL, after the ENDEXEC statement, SY-DBCNT contains the number of lines processed. In nearly all cases, SY-SUBRC contains the value 0 after the ENDEXEC statement. Cursor operations form an exception: After FETCH, SY-SUBRC is 4 if no more records could be read. This also applies when you read a result set using EXEC SQL PERFORMING.
    EXEC SQL PERFORMING loop_output.
      SELECT connid, cityfrom, cityto
      INTO   :wa
      FROM   spfli
      WHERE  carrid = :c1
    ENDEXEC.
    Pls. Mark If useful

  • How to execute this SQL Query in ABAP Program.

    Hi,
    I have a string which is the SQL Query.
    How to execute this sql Query (SQL_STR) in ABAP Program.
    Code:-
    DATA: SQL_STR type string.
    SQL_STR = 'select * from spfli.'.
    Thanks in Advance,
    Vinay

    Hi Vinay
    Here is a sample to dynamically generate a subroutine-pool having your SQL and calling it.
    REPORT dynamic_sql_example .
    DATA: BEGIN OF gt_itab OCCURS 1 ,
    line(80) TYPE c ,
    END OF gt_itab .
    DATA gt_restab TYPE .... .
    DATA gv_name(30) TYPE c .
    DATA gv_err(120) TYPE c .
    START-OF-SELECTION .
    gt_itab-line = 'REPORT generated_sql .' .
    APPEND gt_itab .
    gt_itab-line = 'FORM exec_sql CHANGING et_table . ' .
    APPEND gt_itab .
    gt_itab-line = SQL_STR .
    APPEND gt_itab .
    gt_itab-line = 'ENDFORM.' .
    APPEND gt_itab .
    GENERATE SUBROUTINE POOL gt_itab NAME gv_name MESSAGE gv_err .
    PERFORM exec_sql IN PROGRAM (gv_name) CHANGING gt_restab
    IF FOUND .
    WRITE:/ gv_err .
    LOOP AT gt_result .
    WRITE:/ .... .
    ENDLOOP .
    *--Serdar

  • 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

  • Patterns to execute a SQL Statement from a Droplet (select)

    Hi,
    I need to perform a query on a table, Example: select * from ARF_QUERY "the database used is Oracle. I would like to know if the atg has some
    standard method to perform this database connection and execute the SQL statement from a Droplet (select).
    Thank.

    I dont think there is any generic droplet to run a select query directly against a table.
    However, there are various lookup droplets available that run on the repositories.
    Like /atg/targeting/RepositoryLookup droplet. you can run it for specific id or for all.
    You might want to have a look at it in documentation of how exactly to use it.
    Thanks

  • How to execute a jsp instruction from a java class?

    How to execute a jsp instruction from a java class?
    Any help please.
    Thank's

    I'll detail my problem:
    Supposing that I have a jsp file called: start.jsp
    In the start.jsp I instanciated an object called global from the class Global ( for example ).
    Then, I called a custom taglib:
    <ix:mytag/>
    In the suitable tld file: the mytag is defined:
    <tag>
    <tag class>Tag1<.....
    The java file Tag1 has method:
    doStartTag(){
    // here is the problem
    global.doSomeFunctions();
    Okay, the problem is that the object gobal is not defined in the class Tag1. what to do?
    I think that I have to pass the object global as a parameter to the class Tag1. How to do that?
    Actually, the problem was to insert the follwoing in the doStartTag method:
    doStartTag(){
    pageContext.getOut().print("<%= hello world %>");
    The output is <%= hello world %> not hello world.
    Okay, the new problem is how to pass an object as a parameter to a class called from a tld file.
    Any help please.
    Thank's too much

Maybe you are looking for

  • Safari crashes everytime I open it

    Safari crashes every time I try to open it

  • Firewire issues with DV camera

    When connecting a Samsung VP-D305i mini DV camera to the firewire port (4pin to 6pin cable) Mac OS fails to recognise it. I know this is an issue that has been covered in this forum a few times, but none of the answers seem to work for me. Furthermor

  • Network LOD support for All Paths between 2 nodes

    In the in-memory Network API, there is a method NetworkManager.allPaths. This method returns available paths between 2 nodes with possible constraints. I am looking for a similar method in the LOD NetworkAnalyst class and am not finding it. Is there

  • UnDeploying EAR from Oracle App server using Ant Script

    I am trying to deploy & undeploy the ear file using the ant script. I am using the following script to undeploy the application           <target name="undeploy" description="Undeploy Application">           <java jar="${OCM_DIR}/jdev/lib/oc4j_remote

  • Always pop-up  error mesage when i run the cd-rom program

    Always pop-up  error mesage when i run the cd-rom program - Macromedia Projector發生問題,必須關閉,謹此致歉