continuously run a query in sql prompt

Hello

We want to run a query that shows the current sessions connected, the application must run continuously from the sql prompt.

Select INST_ID select NŒUD, count (*) Current_sessions of GV$ SESSION where username IN ('XxX', 'XXX') group by order INST_ID select 1;

Can it be implemented with a kind of stored procedure that runs in a loop with a time interval?

Any help would be much appreciated.

Thanks in advance!

user-1221 wrote:
I wonder if do you the same thing with your PHB :)

in any case, I created a small batch file and scheduled it with the Windows Task Scheduler, hope this will give him satisfaction.

Thank you for you answer.

But that does not make him have to pick up the results? And who does not lack the "requirement" for "continuous"?

Maybe something like this will satisfy the e-Director of Information and Office Automation

--- cmd file
:query
sqlplus scott/tiger@orcl @run_query
goto query

--- sqlfile:  run_query.sql
set echo off
select inst_id NODE,
       count(*) Current_sessions
from GV$SESSION
where username IN ('XxX','XXX')
group by inst_id
order by 1;
select to_char(sysdate,'dd-Mon-yyyy hh24:mi:ss') CurrentTime from dual;
prompt Are we there yet?
exit

Edited by: EdStevens may 25, 2013 08:30

Edited by: EdStevens may 25, 2013 08:32

Edited by: EdStevens may 25, 2013 13:35

Tags: Database

Similar Questions

  • error in the table of boat or view does not exist, but on query sql prompt works

    Hello
    Can someone help me understand the error ORA-00942: table or view does not exist when compiling the package on Oracle 9.2.0.4.0

    The below package compiled in the use of the system and trying some queries against the view v$ session_wait however getting error below.

    PACKAGE OF THE BODY SYSTEM. PK_DB_ALERT
    Online: 212
    PL/SQL: ORA-00942: table or view does not exist

    I can run the same query mentioned below sql prompt the user of the system, and it works very well however he dislikes package, please advice, thank you in advance.


    SELECT SID, seq #, event, wait_time
    V $ session_wait
    WHERE event NOT LIKE ' SQL * Net %' AND wait_time <>0
    ORDER BY 2

    DDD says:
    Hello
    Can someone help me understand the error ORA-00942: table or view does not exist when compiling the package on Oracle 9.2.0.4.0

    That means package owner is granted select view not directly, but through roles. However, the roles are ignored by stored rights define or packages stored procedures or functions/triggers... You must grant select owner directly the view package.

    SY.

    Published by: Solomon Yakobson, January 21, 2010 04:06

  • I have some problem in my query to sql server. If I press f5 to run it opens to record dialogue area nd do not run (I don't get successful... orders etc). Please help me

    I have some problem in my query to sql server. If I press f5 to run it opens to record dialogue area nd do not run (I don't get successful... orders etc). Please help me

    Hello

    SQL Server is not supported in these forums. I suggest that you ask your question again in one of the forums dedicated to Microsoft for him here:

    http://social.technet.microsoft.com/Forums/en-us/category/sqlserver .

    Thank you.   :)

  • Error message when I run delete the query in SQL Server 2008.

    Error message when I run delete the query in SQL Server 2008 SP3.

    Error message:

    MSG 0, level 11, State 0, line 0
    A serious error occurred on the current command.  The results, if any, should be discarded.

    I never got any problem since 5 years.

    Please let me know what is the cause of the problem.

    You can get a response better/faster if repost you your question in the instances of SQL Server dedicated from Microsoft here:

    http://social.technet.microsoft.com/Forums/en-us/category/sqlserver .

    Thank you.   :)

    (I'm sorry, but I can't move this thread for you because the two forums are working on separate platforms)

  • How export (unload) result of the query without running query on sql developer

    Hello

    I want to know how export (unload) result of the query without running query on sql developer.

    I know this way.
    1. execution of query
    2. click on "Download" on the results tab
    http://i.stack.imgur.com/CQ4Qb.jpg


    Is he available unload a query result before the race?

    No, but you can do this ask the developer SQL change however, for other users can vote and add weight to the possible future implementation.

    Kind regards
    K.

  • Is it possible to run the query created in Discoverer Plus (v10) from PL/SQL

    Hello

    As a subject - is it possible to create a PL/SQL code (or any other), who runs a query saved in Discoverer?

    Concerning
    Piotr

    Hello

    This table is not part of the discoverer EUL and is probably maintained by a trigger of discoverer. The trigger can save the SQL used in the workbook in a custom table when the workbook is run. This is why the table will contain the last SQL for all workbooks that have been executed. It may be what you want but does not contain the last SQL for all workbooks.

    Rod West

  • Run the query in accordance with condition

    Oracle 10g version

    Hi gurus

    I have the following data

    Examples of data

    SELECT DeptNo FROM scott.emp

    UNION ALL

    SELECT EmpNo FROM scott.emp

    ;

    Now what I want is I want to execute conditionally of those surveyed, something like below:

    If list_item = 'I', then run below

    SELECT DeptNo FROM scott.emp

    otherwise run below

    SELECT EmpNo FROM scott.emp

    End if;

    ------

    I want to keep the union all and run the query under the terms...

    Set a long tank (max 4000)

    L_WHERE_CLAUSE

    Use it in your application as a substitution variable by prefixing with &

    WHERE & L_WHERE_CLAUSE

    Assign the value into a pl/sql block (trigger, formula column)

    IF condition THEN

    L_WHERE_CLAUSE: = '1 = 1';

    ON THE OTHER

    L_WHERE_CLAUSE: = '1 = 2';

    END IF;

    Now, among the options that have been suggested to you and the information you provided, I think the solution of Solomon should be easier. Just refer to the column list_item has a link within your query variable (assuming that this and the query where list_item belongs are related, for example, there is a join between them)

    SELECT DeptNo FROM scott.emp, t

    WHERE: list_item = 'l '.

    UNION ALL

    SELECT EmpNo FROM scott.emp, t

    WHERE nvl(:list_item,'x')! = « l »

  • [ADF, JDev 12.1.3] To run a query on the fly is always necessary to define a VO? How to get the Id of the last line inserted in a VO...

    Hallo,

    Sometimes, in the code for my application, I need to run smaller queries to retrieve data from the database.

    I wonder if for these queries, it is necessary to define a View object or if I can avoid this for example creation and execution of a VO on the fly.

    In this case I would not define a VO, given that queries will be never used to display data, but only for the internal logic.

    A use case, I want to solve it next.

    I would like to create a function to be used after validation for last inserted record by a user in a TableVO.

    For example

    Select the Id of the Table where UserId =? and Type =?

    The query should be run in a managed bean...

    public String okButton_action() {}

    OperationBinding operationBinding is BindingsUtils.getBindings () .getOperationBinding ("Commit");.

    Object result = operationBinding.execute ();

    If (! operationBinding.getErrors () .isEmpty ()) {}

    Error handling

    return;

    }

    Here, I need to:

    1. run the query to get the Id of the last inserted record

    2 call the setCurrentRowWithKey on the TableVO to update the display

    and get the Id (identity/auto-increment) than the database

    assigned to the field

    return "return";

    }

    If I can create a function that creates / runs the VO on the fly and return the value ID... It is best to create it in a class of public services or in the implementation class TableVO?

    I need to get the Id of the last line inserted since the ADF is not able to manage MS SQL Server identity fields (it seems that REFRESH AFTER INSERT cannot be used with non - Oracle DB).

    Any notice will be welocome.

    Thank you

    Federico

    The query should be run in a managed bean...

    Much better to execute the query in the template project.

    Example query: http://amit-adf-work.blogspot.com/2013/09/how-to-execute-sql-using-adf-application.html

    If I can create a function that creates / runs the VO on the fly and return the value ID... It is best to create it in a class of public services or in the implementation class TableVO?

    If you have the function that accepts the SQL as a parameter, then this should go to class util.

    Dario

  • How to display the current time inside the SQL prompt

    Hi all;

    I want to know how to set the time permanently in the SQL prompt.

    I'm running oracle database (10 g) on linux (5.5) machine.

    Thanks in advance.

    There under the name [g] login.sql file under ... sqlplus\admin (probably X:\xxx\product\11.2.0\client\sqlplus\admin), this file is executed whenever you connect to sqlplus. You may need to place ' set time on "in this file and save.

  • Is it possible to run a query of IdocScript with GET_SEARCH_RESULTS of Service?

    Hi all

    I need to run the query with GET_SEARCH_RESULTS service below.

    xSubmissionDate "ArchivePackage" < AND > dDocType < match > < 8 October 13 11:03 ' < AND > xArchiveDocName < EQUALS > dDocName


    Part of this query works fine, but when the part in BOLD is also used I get an error, reason be there there is nothing like < EQUALS > when you use the Query Builder


    Instead it is possible to run the idocscript with any service below?


    <$ (dDocType as "ArchivePackage") & xSubmissionDate < dateCurrent(-365) & (XArchiveDocname == dDocname) $>

    I tried with GET_SEARCH_RESULTS, but received erroneous results and no mistake.

    Is this even possible or should I just change my approach?

    Concerning

    What about the GET_DATARESULTSET service?

    required params:

    dataSource = Documents

    resultName =

    whereClause = (revisions.dDocType = 'ArchivePackage' AND DocMeta.xArchiveDocName = Revisions.dDocName and...) / / pure SQL where clause

  • Able to run a query into a TOAD, but cannot create explain plan

    Hello

    I can run a query into a FROG that uses the table to the other schema. I created the synonym and given rights over it.
    But when I try to explain the plan using TOAD: I get Ora - 00942:Table or view does not exist.
    Any suggestions...

    Thank you...

    user8941550 wrote:
    Hello

    He asks me the password for the DBA. I don't have that.
    Is there another way...

    If you do not have access to create the necessary objects on the database, you will not be able to use TOAD explain plan function, you will need to stick with the SQL * more to explain the method of diet (which to be honest is a better plan to explain anyway).

    If you need create these objects, you'll have to ask your DBA to get approval, or get the DBA to create.

  • Query in sql server from Oracle 9.2

    Hello

    How can I connect and run the query to Oracle without using other products (DG4MSQL, etc)?






    using 9.2.08

    Hello
    I say it is 'free' because Dg4ODBC is included in your license of RDBMS and simply provide a third party ODBC driver.
    See this note-

    Gateway and connectivity generic licensing considerations (Doc ID 232482.1)

    You must install and configure in an ORACLE_HOME on a machine somewhere then you can use the links in the database to connect to and select databases non-Oracle.
    Take a look at these notes depending on the platform that you plan to use-

    How DG4ODBC Setup on Linux x 86 32 bit (Doc ID 466228.1)
    How to set up DG4ODBC on 64 bit OS Unix (Linux, Solaris, AIX, HP - UX Itanium) to connect to Oracle databases Post Install (Doc ID 561033.1)
    How the installer DG4ODBC (gateway for ODBC Oracle database) on Windows 32 bits (Doc ID 466225.1)
    How the installer DG4ODBC (gateway for ODBC Oracle database) on 64-bit Windows operating systems (Doc ID 1266572.1)

    As I said in my previous update if SQL * Server is your non-Oracle database then a stand-alone installation on Windows is the best option in order to use the Microsoft ODBC driver, although there is now a Linux x 86-64 bit available MS ODBC.

    Please read carefully the notes that I called because they should have the information you need.

    Kind regards
    Mike

  • the variable name of database query to SQL Server using the Oracle database link

    Hi all

    I have an ApEx 4.1 application running on x 64 (11.2.0.1) 11g on Windows Server 2008 x 64, and I have a few points of data integration with SQL (2005 and 2008) server that I need to create. I have configured the database with dg4odbc link and it works perfectly... I can run queries on the SQL Server database without any problem using the database link.

    However, there is a scenario where the SQL Server database name is dynamic, and I need to generate on the fly in a PL/SQL block and then use it in a query dynamic SQL (all this in the ApEx). It of wherever I meet problems... when I asked the default database that is based on the ODBC connection and I don't have to specify the name of the database, no problem. But when I need access to one of the several other databases by default, I received the error "invalid table.

    It works well:* (note that 'fv' is the name of my database link)

    v_query1: = "select 'Release Date' from dbo." Schedules@FV where dbo. Annexes. "" SchedID "=: calendar";
    EXECUTE IMMEDIATE v_query1 in rel_date using the grid.




    I then take this rel_date variable, convert a varchar2 (rel_date_char), then use it as the name of the database in the following query...


    _ It returns an error(error ORA-00903: invalid table name)

    v_query2: = "select"PARTNO": rel_date_char.dbo.ProdDetails@fv where 'SchedID' =: calendar and"UnitID"=: unit"
    and 'MasterKey' =: master and "ParentKey" =: parent';

    EXECUTE IMMEDIATE v_query2 in part_number using planning, master, parent unit;



    I also tried using all of the following conditions without result:

    "select"PARTNO"of" | : rel_date_char | '.dbo. ProdDetails@fv where 'SchedID '...
    "select"PARTNO"of" | rel_date_char | '.dbo. ProdDetails@fv where 'SchedID '...
    "select"PARTNO"of" | @rel_date_char | '.dbo. ProdDetails@fv where 'SchedID '...
    "select"PARTNO"in @rel_date_char.dbo.ProdDetails @fv where 'SchedID'..."


    Is it possible to do it in PL/SQL?

    Thanks for any help!
    -Ian C.

    Published by: 946532 on July 15, 2012 19:45

    Just did a test using passthrough:

    SQL > set serveroutput on
    SQL > declare
    2 val varchar2 (100);
    3 c whole;
    4 whole nr;
    5. start
    c: 6 = dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, "select count (*) from EMP");
    8 LOOP
    9 nr: = DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
    10 output when nr = 0;
    11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 1, val);
    12 dbms_output.put_line (val);
    13 end of loop;
    14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
    15 end;
    16.
    24576

    PL/SQL procedure successfully completed.

    SQL > declare
    2 val varchar2 (100);
    3 c whole;
    4 whole nr;
    5. start
    c: 6 = dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, ' select count (*) from dbo.) EMP');
    8 LOOP
    9 nr: = DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
    10 output when nr = 0;
    11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 1, val);
    12 dbms_output.put_line (val);
    13 end of loop;
    14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
    15 end;
    16.
    24576

    PL/SQL procedure successfully completed.

    So all 3 ways work for me.

    Published by: kgronau on July 23, 2012 10:08

    Now, using the variables to make the selection:

    SQL > declare
    2 val varchar2 (100);
    3 c whole;
    4 whole nr;
    5 tabname varchar2 (20): = 'EMP ';
    6 ownr varchar2 (20): = "dbo."
    7 dbname varchar2 (20): = "door";
    Start 8
    c: 9 = dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    10 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, ' SELECT count (*) FROM ': dbname: '.) ' || ownr | '.'|| tabname | ") ;
    11 LOOP
    12 nr: = DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
    13 when the exit nr = 0;
    14 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 1, val);
    15 dbms_output.put_line (val);
    16 end loop;
    17 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
    18 end;
    19.
    24576

    PL/SQL procedure successfully completed.

    => instead of executing the statement using the "execute Immediate" we use the PASTHROUGH package to pass the statement to SQL Server.

    Published by: kgronau on July 23, 2012 10:10

  • How do I run the query by quarter

    Hi all,
    I would like to run this query based on the users selection from the interface. For example if the user select year 2011 and quarter 1, then   this code will be like this                   
                            AND (B.DATELET >= TO_DATE ('2011-01-01', 'YYYY-MM-DD')
                            AND B.DATELET <= TO_DATE ('2011-03-31', 'YYYY-MM-DD'))
    When the user select year 2011 and quarter 2 then this code will be like this
                            AND (B.DATELET >= TO_DATE ('2011-04-01', 'YYYY-MM-DD')
                            AND B.DATELET <= TO_DATE ('2011-06-30', 'YYYY-MM-DD'))
    Will this possible to change my code here or I need to code this in PL/SQL?  any clue will be appreciated.
    
    SELECT DISTINCT
             COUNT (P.CPROJNUM) ProjectAwarded,
             SUM (MIN (c.calcbtot)) AwardedDollarAmount,
             SUM (COUNT (C.VENDOR)) NumberOfBidders,
             (SUM (COUNT (C.VENDOR)) / (COUNT (P.CPROJNUM))) AverageNumberOfBidder
        FROM BIDDERS C,
             BIDLET B,
             LETPROP L,
             PROPOSAL P
       WHERE     C.LETTING = B.LETTING
             AND P.CONTID = L.LCONTID
             AND C.LETTING = L.LETTING
             AND C.CALL = L.CALL
             AND l.lcontid IN
                    (SELECT lcontid
                       FROM letprop c, PROPOSAL d
                      WHERE     datestat IS NOT NULL
                            AND UPPER (letstat) <> 'R'
                            AND UPPER (letstat) <> 'B'
                            AND TRIM (UPPER (TIMELET)) = TRIM ('9:30 A.M.')
                            AND c.LCONTID = d.CONTID)
                            AND (B.DATELET >= TO_DATE ('2011-04-01', 'YYYY-MM-DD')
                            AND B.DATELET <= TO_DATE ('2011-06-30', 'YYYY-MM-DD'))              
            
    GROUP BY l.call

    Hello

    If: p_year and: p_quarter are variables NUMBERS, container of the year and the quarter you want, then you can do something like this:

    WITH     got_report_start_date     AS
    (
         SELECT  ADD_MONTHS ( DATE '2000-01-01'
                      , (12 * (:p_year - 2000)) +
                        ( 3 * (:p_quarter - 1))
                      )   AS report_start_date
         FROM    dual
    )                                        -- Everything above is NEW
    SELECT DISTINCT
             COUNT (P.CPROJNUM) ProjectAwarded,
             SUM (MIN (c.calcbtot)) AwardedDollarAmount,
             SUM (COUNT (C.VENDOR)) NumberOfBidders,
             (SUM (COUNT (C.VENDOR)) / (COUNT (P.CPROJNUM))) AverageNumberOfBidder
        FROM BIDDERS C,
             BIDLET B,
             LETPROP L,
             PROPOSAL P
       ,      got_report_start_date     r                    -- NEW
       WHERE     C.LETTING = B.LETTING
             AND P.CONTID = L.LCONTID
             AND C.LETTING = L.LETTING
             AND C.CALL = L.CALL
             AND l.lcontid IN
                    (SELECT lcontid
                       FROM letprop c, PROPOSAL d
                      WHERE     datestat IS NOT NULL
                            AND UPPER (letstat) <> 'R'
                            AND UPPER (letstat)  'B'
                            AND TRIM (UPPER (TIMELET)) = TRIM ('9:30 A.M.')
                            AND c.LCONTID = d.CONTID
              )
             AND B.DATELET >= r.report_start_date               -- CHANGED
             AND B.DATELET <  ADD_MONTHS (r.report_start_date, 3)     -- CHANGED
    

    Look at the comments that say NEW or MODIFIED; the rest is just what you've posted.

    Note that you must use < (not=""> <=) when="" testing="" the="" end="" of="" the="" date="" range,="" and="" the="" date="" after="" the=""> < sign="" is="" the="" first="" date=""> NOT be included in the results.

  • How can I run beginddl in PL/SQL Developer

    Here is my script:

    Start
    execute dbms_wm.beginddl ('MyTable');
    ALTER TABLE MyTable ADD NewColumn1 VARCHAR2 (200)
    execute dbms_wm.commitddl ('MyTable');
    end;

    I got the following error:


    ORA-06550: line 2, column 11:
    PLS-00103: encountered the symbol "DBMS_WM" during the expected in the following way:

    := . (@ %; immediate)
    The symbol ': = ' was replaced by "DBMS_WM" continue.
    ORA-06550: line 3, column 3:
    PLS-00103: encountered the symbol "ALTER" when expecting one of the following conditions:

    (begin case declare exit end exception for goto if loop mod)
    pragma raise return null select update while with
    < an ID > < a limit between double quotes


    What should I do next?

    Thank you.

    in the PL/SQL scripts, you simply omit the 'run '. and for the SQL code, you must put a run before.
    so your script:

    begin
      dbms_wm.beginddl('MyTable');
      execute immediate 'ALTER TABLE MyTable ADD NewColumn1 VARCHAR2(200)';
      dbms_wm.commitddl('MyTable');
    end;
    

    Apart from that, you should edit MyTable_LTS in your session DDL.

    Kind regards

    Andreas

Maybe you are looking for

  • Apple News App

    Whenever I try to open my 'News' application, it will open for a second or two and then immediately stops. All my other applications without any problem. Everyone knows about this problem?

  • I have a problem emting my trash

    There a PDF in there and when I try to vacuum, it indicates the pdf file is in use and I my can continue, skip, stop I pressed each one and it won't erase what I'm missing

  • How to give endpoint network Stream as input/output for a Sub VI

    I have a program to write data to a stream and to read using the host. In the reader program, I have a Subvi, which I need to pass endpoint network Stream. I'm unable to do so. https://decibel.ni.com/content/docs/DOC-15920, in the program in the link

  • Wireless series ENVY 110: invitation envelopes printing

    I use Print Shop on my MAC computer.  I would like to address the envelopes of invitation on the ENVY 100 printer.  He said to me that I use paper wrong size when I put the envelopes in the printer. How to program the printer to accept E-6 envelopes?

  • Why film bars (empty space) are prohibited?

    I did a side-scrolling game that was approved the month back. Then when you submit a minor update, it was not approved due to a change in policy which prohibits the existence of film bars. Horizontal scrolling is optimized for 16:9 and will just scal