Tracking the order of execution of sql scripts in SQL*Plus

In our production environment we sometimes have to run some .sql scripts in a particular order. Since the order of execution is important , i have created another .sql file caller caller.sql(shown at the bottom) which will call all the scripts in the right order.
i thought of putting a exec DBMS_LOCK.SLEEP (5); after the end of every execution of the script so that i can see the
'Ending script1'message .
The spooling within the caller script(execute_stack.log) has become meaningless because each script has a spool <filename.log> and spool off within it. These spool logs (for every script) is important for tracking purposes as each script belongs to a different development team and i have to send them the spooled log file after the execution.
I don't want to see the entire scripts running by in my screen. Since these scripts have their own spooling, i can later check the logs if the scripts where executed properly.
So i need two things.
1.I just need to see the following and nothing else in the screen.
Ending script1
Ending script2
Ending script3
.2. I need to log the order of execution. ie. the execute_stack.log should look like the above.Since there is a spool off within each script, this wouldn't be possible.Right?
Ending script1
Ending script2
Ending script3
.The caller.sql script which calls all the scripts in the right order
alter session set nls_date_format = 'DD-MON-YYYY hh24:MI:SS';
set serveroutput on
set echo on;
set feedback on;
spool execute_stack.log
@script1.sql
exec dbms_output.put_line ('Ending script1');
dbms_output.put_line(chr(10)||chr(10)||'.'||chr(10)||'.'||chr(10));
exec DBMS_LOCK.SLEEP (5);
@script2.sql
exec dbms_output.put_line ('Ending script2');
dbms_output.put_line(chr(10)||chr(10)||'.'||chr(10)||'.'||chr(10));
exec DBMS_LOCK.SLEEP (5);
@script3.sql
exec dbms_output.put_line ('Ending script3');
dbms_output.put_line(chr(10)||chr(10)||'.'||chr(10)||'.'||chr(10));
exec DBMS_LOCK.SLEEP (5);
@script4.sql
dbms_output.put_line(chr(10)||chr(10)||'.'||chr(10)||'.'||chr(10));
exec dbms_output.put_line ('Ending script3');
commit;
spool off;Is this a professional way of tracking the execution of .sql scripts?

Pete_Sg1 wrote:
Is this a professional way of tracking the execution of .sql scripts?No. There is very little professional about using .sql scripts on a production system - when stored procedures are safer, more robust, easier managed and controlled and secure.. and where a log table can be used to properly log the runtimes (and other stats) of each processing step.
Let's just take a look at the number of moving parts you need to schedule and run a .sql script. A cron job needs to be configured with the proper environment setting. It needs to run a shell script. That shell script needs to load SQL*Plus. SQL*Plus needs to connect to the database (starting a dedicated server process most likely). SQL*Plus then needs to read a .sql file, parse these commands and either execute these locally (SQL*Plus commands) or remotely (PL/SQL and SQL commands).
How can this be considered professional when the very same can be achieved with a
- stored procedure
- using DBMS_JOB to schedule the procedure for execution
There are so many things that can go wrong with the first method. And so few things that could go wrong with the last one. No contest as to which method is not only better, but also professional.
PS. See that you use Windows to run these scripts. It is even worse as it introduces another hardware and software layer making the scenario even more insecure & unsafe with more moving parts that can go wrong or simply fail.

Similar Messages

  • The order of execution (of PL/SQL function calls) changes...why??

    select e.EMPID empid,
    e.name name,
    aatest.SETVALUES(2) z,
    aatest.TEST1() b,
    aatest.TEST2() x,
    aatest.TEST3() y
    from emp e
    where e.empid = 101
    order by e.name;
    when I execute this select statement...the order of function calls is as follows:
    setvalues 1st (call no:1)
    test1 (call no:2)
    test2 (call no:3)
    test3 (call no:4)
    Now...I introduce a join between the two tacles as mentioned in the query
    select e.EMPID empid,
    e.name name,
    e2.deptno deptid,
    aatest.SETVALUES(2) z,
    aatest.TEST1() b,
    aatest.TEST2() x,
    aatest.TEST3() y
    from emp e, emp2 e2
    where e.empid = e2.empid
    order by e.name;
    The order of execution of function calls changes to
    (I observed this using DBMS_OUTPUT.PUT_LINE)
    test3 (call no:1)
    setvalues 1st (call no:2)
    test1 (call no:3)
    test2 (call no:4) (the first and last calls swap!)
    i.e: it calls the last function in the select statement at the beginning
    instead of calling it at the last. Is it the normal behaviour? or whats going on
    here?
    Can somebody explain me, please....
    Details:
    the following four functions are defined in a package called 'aatest' and compiled.
    aatest.SETVALUES(2)
    aatest.TEST1()
    aatest.TEST2()
    aatest.TEST3()
    the Tables EMP and EMP2 are two tables defined in the same schema.

    Your "thinking" is wrong here. You can not use the column order to model your program flow. As SQL is set/tupel based, there is no given sequence of the execution order. Otoh you want to have a specific order in wich your functions must be executed otherwise the result will be wrong (or undefined). Thus here you need a procedural approach. This can be done by using PL/SQL for example.
    You would code your functions in that way, that they are working correctly independent from the place where they are called ie if function1 needs the setvalues function, this function must be called inside the function1 then.
    Are you sure you need all these functions in this procedural approach inside the sql-statement? This is mostly not needed and can be accomplished by using pure SQL. If not, may be your design is broken.

  • What is the order of execution of global transfer routine where multiple routines are involved?

    Hi,
    Suppose we have start routine, transformation routines and end routine defined between datasource and data target, and also we have a global transfer routine created on an infoobject.
    What is the order of execution of routines in this scenerio?
    Also if conversion routine like ALPHA is defined for an Infoobject, when does this come into flow.?
    Please enlighten me.
    Thanks,
    Akshara

    Hello Akshara ,
    The sequence of routines are as
    1. Start Routine
    2. Master Data Look Up or
    3. Field Level Routine
    4. End Rountine
    Apart from this , there is Expert routine, which is used in special cases, when there are not the sufficient functions to perform a transformation. It can be used as a interim solution , and it performs all the  functions of Start routine, end routine , field routine.
    Note : if you have created  transformation, and then created Expert routine, then system will delete all the existing transformations.
    Further to this, you can explore more, by debug the transformation as suggested by Vijay Kumar.
    Hope this helps !
    Regards
    YN

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

  • Statechart Module: What is the order of execution for a parent state and its substates?

    Hello,
    This page describes the order of execution of transitions and actions for one level of nesting. What about compound states? Do the static reactions of the parent state execute before the transitions of the sub-states?

    Hello, 
    I'm not incredibly familiar with the Statechart module, but I will look into it for you on our internal database. In the mean time, there are some examples that may answer some of your questions here:
    https://decibel.ni.com/content/docs/DOC-8716
    and here:
    http://www.ni.com/white-paper/7425/en
    -N
    National Instruments
    Applications Engineer

  • How can we track the order of rework

    Hi guru's,
    We have created one rework order scenario without material.
    Noe client requirement is that they want to track the rework order from its original order.
    Is thre any report which gives the trail. As we can't put Batch number in rework order, it's difficult to track batchwise.
    Thanks in anticipation

    I think "Order type" along with "Material Code" will be helpful to filter such requirement.
    It seems some manual work also.
    Chintan

  • How to change the order of execution

    How to make a table driving table in the list of joining tables in the from clause?
    for
    select count(1)
    from
    table_a a , table_b b , table_c c
    where a.col1=b.col1
    and b.col2 = c.col2
    I know that we can use ordered hint to make oracle the use the ordered mentioned in the from clause.
    How about joinng order in the where clause.
    Do I need to give any extra hints.
    I understand a bit of checking oracle execution path.
    Is there any material which can give me insight of the same.
    thanks in advance

    Hi,
    hints should be used when there is no way to obtain a correcte execution path having objects analyzed and properly setup.
    In that case, the /*+ ORDERED */ hint after the SELECT clause forces the execution plan to follow the execution order based on the FROM clause.
    Be aware that, if if You have more than 2 tables in the from clause, You can have a Cartesian Product if the from clause is not properly set.
    Hope this helps
    Max

  • After running sql scripts in SQL plus, where are the results(tables) stored

    Hi ,
    I am using oracleDb10g . i have used SQL plus to create a database. I have run 2 sql scripts and constructed the tables , but i dont know where the data is stored and how to make the data into a database, so that i can use it for connection through some UI.
    for example: schema.sql, data.sql script files.
    SQL> start schema.sql
    SQL> start data.sql
    The tables are created.
    Now how can i group those table into a database and name it.(i mean i can create a database using SQL plus, but how to dump the tables into the database created). Because i want to use this database name for connecting to MS SQL, so i need the name.
    Thanks
    babu.

    when you are in Rome, sing with the romans !
    Oracle is different from SQL Server.
    Time to read some basic books.
    --> http://tahiti.oracle.com

  • "ORA-1722 Invalid number" error while runing a SQL script in SQL*Plus

    Hello,
    I created a SQL script that is intended to populate tables with
    baseline data. When I run the script in the SQL*Plus program
    that comes with the Oracle 8.1.6 (client), I receive an "ORA-
    1722 Invalid number".
    The error always occurs when SQL*Plus tries to execute the
    following SQL statement:
    insert into components(db_ind,module_id,ext_compid,active) values
    ('cm',modules_seq.currval,1046682,'y');
    The datatypes for the columns on the components table are as
    follows:
    db_ind varchar2(2);
    module_id number;
    ext_compid number;
    active varchar2(1);
    It seems that for some reason Oracle is having trouble
    recognizing 1046682 as a number.
    I also tried the following INSERT statements to see if that
    would work:
    insert into components(db_ind,module_id,ext_compid,active) values
    ('cm',modules_seq.currval,to_number('1046682'),'y');
    insert into components(db_ind,module_id,ext_compid,active) values
    ('cm',modules_seq.currval,'1046682','y');
    but I still receive the same error message
    Is there some NLS setting(s) I need to modify so that Oracle
    does not give me this error? Does anyone know the answer to
    this problem?
    Your help is greatly appreciated.
    Oscar
    (NOTE: I also receive this same error when trying run the
    script in SQL Navigator and Toad programs)

    Please see the following docs.
    R12: JBO-27122 Error Message Clicking On Supplier Accounting Link With Unexpected Error [ID 1218903.1]
    Supplier Management Accounting Link Gives Unexpected Error and JBO-27122 at SELECT * FROM (select pvsa.ADDRESS_STYLE [ID 1340655.1]
    Adding Accounting Information or Operating Unit Information fails with APP-FND-1564: ORACLE error 1722 in FDFGVD [ID 364265.1]
    Thanks,
    Hussein

  • Need command to run sql script from sql prompt

    Hi,
    I am beginner in sql i need a command to run sql file from sql prompt.In notepad i have write 10 to 15 tables creation and saved as .sql i want to run this file from sql promp pls some one help.I am very great full to all users in this forum.

    You can also use the 'start' command.
    You may also want to look in the SQLPlus User Guide and Reference (for your release) at the set command for commands to set the number of lines per page, turn headings on or off, and so on:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10823/toc.htm
    HTH -- Mark D Powell --

  • Infopath form, one approve button with three rules, what is the order of execution

    i have designed a approval form the the "approval" button, it has three rules, one is submit to host, the second is set value to one field, the last one is to close form.
    some times, especially when the server is too busy, the first rule execute a long time, at last it seams fail, but the second and the last execute ok.
    that is, the workflow status is NOT START, but the value is set and the form is closed.
    when the approver open the workflow, the approval form check the stateValue is changed, the form show one "already approvaled" view. but the workflow still NOT START.
    i am very confused for this, hope someone give me some advices. thanks all guys!
    lixw
    i just know what has just happen. i changed some code, and this make some task been locked.
    thanks everyone!

    Why is the rule for updating a field value is set to execute after form submit? Shouldn't it be prior to submit?
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • Order of execution of named method user properties and server script

    Dear All,
    If for a Custom method on an applet, we have scripts in WebApplet_preinvokemethod and WebApplet_invokemethod and also for the same Custom method we have applet Named Method user properties and BC Named Method user properties, what will be the order of execution of these scripts and Named Method user properties??

    The Private Event Submission sample portlet shows how to achieve this. It is part of the PDK download.
    Peter

  • How to maintain order of execution of the Queries in Data Model

    Hi,
    I have 5 queries in the Data Model
    Query_1 will fetch some values based on the selection criteria and inserts values in a table(say Table_1) using a formula column
    The other queries will fetch data from DB using the records in Table_1
    The problem now i am facing is Query_2|Query_3|Query_4|Query_5 is being executed before Query_1
    How can we maintain the order of execution
    Any help will be appreciated
    thanks
    siva

    No there is no join between Q_1 and other queries
    all the queries are individually hanging in the data model
    moreover we cannot have a Master-Detail kinda relasionship in this case
    please give me some suggestions

  • Can we execution  sql script through java ?

    Hi All,
    Can we execute sql script ("name.sql") through java programe.
    I am not talking about reading sql script one by one and excute.
    I just want to send this sql script to oracle console.
    Or any body can give other alternative I have to lot of db operation in less time.
    - Vikas Kumar Sahu

    Kumar,
    not sure whether this is any help, but you can try and use the code below.
    I've knocked it together in about an hour so it's far from production ready (particularly, assumes one-line comments starting with '#' and nothing else - queries are assumed multi-line, but terminated by ';' the following would cause trouble:
    SELECT * FROM table; SELECT *
    FROM another_table;
    and, of course, you can't get to the ResultSet.
    But, hey, it's a start!
    Best,
    Marco.
    (www.infinitebw.com)
    admin (at) infinitebw.com
    package com.ibw.database;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.sql.*;
    import com.ibw.exception.DatabaseException;
    public class SqlScript {
         public final static char QUERY_ENDS = ';';
         private File script;
         private Connection conn;
         private Statement stat;
         * @param args
         * @throws SQLException
         public SqlScript(String scriptFileName) throws SQLException {
              script = new File(scriptFileName);
    // this is a 'custom' class, just use instead getConnection() from the
    // DriverManager instead
              conn = ConnectionManager.getConn("test");
              stat = conn.createStatement();
         public static void main(String[] args) {
              try {
                   SqlScript sqlScript = new SqlScript("C:/temp/myscript.sql");
                   sqlScript.loadScript();
                   sqlScript.execute();
              } catch (SQLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         protected void loadScript() throws IOException, SQLException {
              BufferedReader reader = new BufferedReader(new FileReader(script));
              String line;
              StringBuffer query = new StringBuffer();
              boolean queryEnds = false;
              while ((line = reader.readLine()) != null) {
                   if (isComment(line))
                        continue;
                   queryEnds = checkStatementEnds(line);
                   query.append(line);
                   if (queryEnds) {
                        stat.addBatch(query.toString());
                        query.setLength(0);
         private boolean isComment(String line) {
              if ((line != null) && (line.length() > 0))
                   return (line.charAt(0) == '#');
              return false;
         public void execute() throws IOException, SQLException {
              stat.executeBatch();
         private boolean checkStatementEnds(String s) {
              return (s.indexOf(QUERY_ENDS) != -1);
    }

  • Order of execution of the user form

    If for Active synch configuration there is one admin assigned who has a form say AdminForm. At the same time there is one Active syncuser form attached say ActiveSynchUser form. What will be the order of execution of the two forms.
    Will the ActiveSynchUserForm gets evaluated first and then the user form attached to the admin or it is other way.

    keep in mind that prcidence in this case means that BOTH forms are executed.
    i believe the form assigned to the active sync is first..then the form assigned to the admin user is second.
    i could be wrong on this as we dont use the admin forms for Active Sync. I have found them to be very limiting in your ability to fulfill requirements. You may wish to look into executing a workflow on each account instead of using the forms. Sun will reccommend using the forms, but again, I have found them to be extremely limiting in practice.
    Dana Reed
    AegisUSA
    Denver, Co
    [email protected]

Maybe you are looking for

  • How to restrict a hold GR document for invoicing

    Dear all, I made the GR against a PO in MIGO. for that document no also generated. But due to some reason i want to hold the document no, so that it can't be further processed. I also hold the same document no by performing "DISPLAY" "MATERIAL DOCUME

  • NEED a java coder to help with a script for a programs of mine.

    I play a game, very competitively, and need someone to make and compile a script for me. I am willing to pay upwards of 100 USD for this script made to MY standards. There will be a lot of work involved...Probably 12 hours studying my game and the pu

  • Backwards compatibility of PDF Forms in Lion

    I work with PDF forms in Preview on a Macbook Pro at my office which is running Snow Leopard 10.6.8. My Mac Mini at home is running Lion 10.7.4. I have found that PDF forms that are edited in Lion after being edited in Snow Leopard end up mostly blan

  • Making some rows non-editable in ALV grid

    hi I am using reuse_alv _grid _display to display the output. I want to make some of the rows non-editable based on some conditions. please help.

  • Component and Panels - newbie

    sometimes panels are directly added and sometimes a Component is created and panels are added to Component and then they are used in JSplitPane. In what kind of situations can we add directly the panel, and when do we need the Component() ? eg final