Query to get list of queries within a specific session.

Hi all,
I want to know the query which will return me all the queries within a session. I have a query which I use quite often, but it returns the last query executed within that session.
select st.sql_text
from v$sqltext st,v$session sn where st.address=sn.sql_address and st.hash_value=sn.sql_hash_value and
sn.sid = <sid> and
sn.serial# = <serial#>
order by st.piece
Could anybody help me.
thanx,

Hi,
Thanx.
I have one more query, does oracle server keep cursors open till end of the transaction or close it immediately as soon as query is successfully executed ? If it's not closing the cursors immediately, why the following query where I am joining v$sqltext, v$session and v$open_cursor is not retruning me all the queries in one transaction. I believe, transaction is queries executed between two successive commit / rollback. The following query is returning me the same resultset as the earlier one.
select oc.sql_text from v$session sn, v$open_cursor oc where sn.sql_address = oc.ADDRESS and sn.sql_hash_value = oc.HASH_VALUE and sn.sid = 8 and sn.serial#= 22769;
Thanx,

Similar Messages

  • Thru OEM get list of queries and their schemas that accessed my objects

    Hi,
    I have a list of objects on my schema and i need to track the list of sql queries by different users that accessed by object during this time period.
    i haven't enabled any auditing yet.
    is there any way i can get that list of queries and their schemas that accessed those particular objects during a particular time period through OEM.
    Can someone guide me please.
    Thanks in advance.
    Philip.

    create a name property in your class and assign a name property to your instances (either in the contructor) and/or using getters/setters.  (you'll need a getter anyway.)

  • Query to get list of linked server tables referenced inside a stored procedure

    Hi,
    SQL Server 2005 sp4
    I have a requirement to get list of linked server tables referenced insider a stored procedure
    Ex:
    Databases       DB1          DB2
    Tables:            T1             T2                            
    Use DB1
    Go
    Create proc P1
    begin
    select * from T1
    select * from DB2.dbo.T2
    end
    I am looking for a query which can return a result with output as below. sp_depends is not helping here as it does not work for cross DB objects, any other thoughts.
    Tables
    T1,
    DB2.dbo.T2

    On SQL 2005, you will have to do it manually.
    On SQL 2008 or later, you could have used sys.sql_expression_dependencies.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to get list of queries .....

    how to get list of all queries on a particular cube, with descriptions?
    (meta data repository is not avilable)

    Hi..
    1. In the Bex you can fild the list of queries under a data target, by opening 'Queries'.
    In the dialog box that appears, select the Infoarea button which is in the left pane.
    You will get list of all Data targets. If you expand it you can find the queries built on those data target.
    2. If you want to get the list of queries from Tables, you have to link the following tables:
    RSZRANGE
    RSZELTXREF
    RSZELTTXT
    RSRREPDIR
    RSZSELECT
    RSZCOMPDIR
    Regards,
    Debjani..

  • Parsing query and getting list of tables used

    Hi All,
       I require to parse sql query (simple & complex as well) and to get the list of tables used in the query.
       And need to validate that, the list of tables against a whitelist to maintained in the file.
      I tried to write my own parser, since there are lots possible ways to write complex queries, i am unable to cover all the scenarios.
      I require a help, Is there any other ways to get the list of tables used in a query?
    Thanks,
    Mahendran..

    user10279893 wrote:
    Hi All,
       I require to parse sql query (simple & complex as well) and to get the list of tables used in the query.
       And need to validate that, the list of tables against a whitelist to maintained in the file.
      I tried to write my own parser, since there are lots possible ways to write complex queries, i am unable to cover all the scenarios.
      I require a help, Is there any other ways to get the list of tables used in a query?
    Thanks,
    Mahendran..
    You'll never cover all scenarios by trying to parse a query.
    For example, what about a query that queries views and those views query pipelined functions, and those pipelined functions query other views or tables or pipelined functions etc.
    And what about a query that dynamically obtains the table names, such as...
    SQL> select
      2    table_name,
      3    to_number(
      4      extractvalue(
      5        xmltype(
      6 dbms_xmlgen.getxml('select count(*) c from '||table_name))
      7        ,'/ROWSET/ROW/C')) count
      8  from user_tables
      9 where iot_type != 'IOT_OVERFLOW'
    10 or    iot_type is null;
    TABLE_NAME                      COUNT
    DEPT                                4
    EMP                                14
    BONUS                               0
    SALGRADE                            5
    .. in this case the tables being accessed (to count their rows) are not even known within the code, they are dynamically generated queries at run-time, so the only way to know what tables are accessed is to actually run the query.
    Of course, a well designed system, with proper documentation and version control would allow you to take any database object and know where and what is using it, and whether it's even being used.

  • Getting list of directories within a directory - NULL

    I am getting a NULL POINTER EXCEPTION when trying to get a list of directories from a directory.
    <%
    main_dir = new File("test_dir");
    dirs = main_dir.list();
    if(dir==null){
    %>
    ERROR: dirs is null<p>
    Main Dir: <%=index_dir%>
    <% }
    %>
    It is returning that message that dirs is null.
    The directory structure is
    $TOMCAT_DIR/webapps/test_dir.jsp
    $TOMCAT_DIR/webapps/test_dir
    Within test_dir are two directories: test1, test2
    I put the same code into a regular java code:
    File f = new File ("test_dir");
    String[] dirs = f.list();
    if(dirs == null){
    System.out.println("dirs is null");
    It DOES NOT print out that message that dirs is null.
    I'm just very confused. What am I doing wrong?

    Pardon me but since I don't put the actual code on here sometiems there are typos.
    I have a program where I open a directory. It's a search page where it displays about 10 results then has a button at the bottom says "next" for the next results.
    Anyhow, one minute the webpage will be fine, open the directory with no problem. Then it will stop and say it can't open the directory when the directory is there. It's driving me nuts.
    I'm using Java code within the JSP page, instead of beans so I dont' know if that causes some kind of error.
    <%
    index_dir = new File(master_index_dir);
    indexes = index_dir.list();
    if(indexes==null){
    %>
    ERROR: indexes is null<p>
    Master Index Dir: <%=index_dir%>
    <% }
    else { 
    // Other stuff
    %>
    Well just 5 minutes ago this worked fine, the index was open and the results shown. However just 2 minutes ago it stopped and returns the message that indexes is null.
    Sometimes if I stop and start tomcat several times it starts to work again.

  • Get list of queries in a role

    Hi,
    Is it possible to get a list of all the queries which are assigned to a specific role?
    I have a role and i want to generate a list of the queries in it via ABAP.
    Regards,
    Karen

    Hi
    I sugest you load the role via trx PVCG.
    then get in to debug mode and track where does the reports/querys comes from.
    Reg's
    Edan

  • Query to get list of customers with partial shipments

    I have a scenario where I need to find customers with open orders.  (Orders and Shipments have 1-to-many relationship ):
    Orders = (order_id PK, cust_id FK, prod_id FK, order_quantity, order_date)
    Shipments = (shipment_id, order_id FK, shipment_quantity, shipment_date)
    Open orders have 2 scenarios:
    1) orders without shipment records
    2) partial shipments:
    e.g. 1 order record with quantity 10.  
    2 records in shipments table, 1 row with quantity 3, and the 2nd row with quantity 4; total shipped quantity is 7, which is less than order quantity of 10
    How can I get this?

    ZaafranAhmed wrote:
    I have a scenario where I need to find customers with open orders.  (Orders and Shipments have 1-to-many relationship ):
    Orders = (order_id PK, cust_id FK, prod_id FK, order_quantity, order_date)
    Shipments = (shipment_id, order_id FK, shipment_quantity, shipment_date)
    Open orders have 2 scenarios:
    1) orders without shipment records
    2) partial shipments:
    e.g. 1 order record with quantity 10. 
    2 records in shipments table, 1 row with quantity 3, and the 2nd row with quantity 4; total shipped quantity is 7, which is less than order quantity of 10
    How can I get this?
    SELECT order_id
    FROM   orders
    WHERE  order_quantity > (SELECT SUM(shipment_quantity)
                             FROM   shipments
                             WHERE  orders.order_id = shipments.order_id);

  • How can I get list of columns used of specific table in all stored procedure?

    How can I get used column list of a specific table in among all stored procedure?
    Suppose that,
    I have a table(VendorMaster) which has 100 columns just I want to know how many columns used in among all stored procedure.

    We have solved by below query...
    IF OBJECT_ID('tempdb.dbo.#SPDependencyDetails') IS NOT NULL
    DROP TABLE #SPDependencyDetails
    CREATE TABLE #SPDependencyDetails
     Or_Object_Database NVARCHAR(128)
    ,Or_Object_Name NVARCHAR(128)
    ,Ref_Database_Name NVARCHAR(128)
    ,Ref_Schema_Name NVARCHAR(128)
    ,Ref_Object_Name NVARCHAR(128)
    ,Ref_Column_Name NVARCHAR(128)
    ,Is_Selected BIT
    ,Is_Updated BIT
    ,Is_Select_All BIT
    ,Is_All_Columns_Found BIT
    DECLARE @database_name VARCHAR(100)
    DECLARE database_cursor CURSOR
    FOR
    SELECT name
        FROM sys.databases
        WHERE database_id =8
    OPEN database_cursor
    FETCH NEXT FROM database_cursor
    INTO @database_name
    WHILE @@FETCH_STATUS = 0 --Outer Loop begin
    BEGIN
        DECLARE  @WholeLotofSQL NVARCHAR(MAX) =       '
        DECLARE @object_name VARCHAR(150)
        ,@sqlstatement NVARCHAR(2500)
        DECLARE object_cursor CURSOR --Inner cursor, iterates list of objects that match type
        FOR
            SELECT name
                FROM '+@database_name+'.sys.objects AS o
                WHERE o.type = ''P'' --Change Object type to find dependencies of Functions, Views and etc.
                ORDER BY 1    
        OPEN object_cursor
        FETCH NEXT FROM object_cursor INTO @object_name
        WHILE @@FETCH_STATUS = 0  --Inner Loop Begin
            BEGIN
                SET @sqlstatement = ''USE '+@database_name+';
                                    INSERT INTO #SPDependencyDetails
                                    SELECT DB_NAME() AS Or_Object_Database
                                            ,'''''' + @object_name + '''''' AS Or_Object_Name
                                            ,CASE WHEN referenced_database_name IS NULL THEN DB_NAME()
                                                    ELSE referenced_database_name
                                            END AS Ref_Database_Name
                                            ,referenced_schema_name AS Ref_Schema_Name
                                            ,referenced_entity_name AS Ref_Object_Name
                                            ,referenced_minor_name AS Ref_Column_Name
                                            ,is_selected
                                            ,is_updated
                                            ,is_select_all
                                            ,is_all_columns_found
                                        FROM sys.dm_sql_referenced_entities(''''dbo.'' + @object_name + '''''', ''''OBJECT'''');''
                EXEC sys.sp_executesql @sqlstatement
                FETCH NEXT FROM object_cursor INTO @object_name
            END      
        CLOSE object_cursor
        DEALLOCATE object_cursor'
        EXEC sys.sp_executesql @WholeLotofSQL
        FETCH NEXT FROM database_cursor INTO @database_name
    END
    CLOSE database_cursor;
    DEALLOCATE database_cursor;
    SELECT Or_Object_Database as 'Database'
    ,Or_Object_Name as 'Procedure'
    ,Ref_Object_Name as 'Table'
    ,Ref_Column_Name as 'Column'
    FROM #SPDependencyDetails

  • CAML query on SharePoint list not working after reaching threshold limit

    I have written CAML query to filter and get list items. It was working fine, but the List items count crossed 5000 and its around 15000 items. In Server Object Model When i execute my query to get list items throws exception as " The
    attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator ".
    My Code:
    SPList list = web.Lists["ComplaintReturnsForm1"];
    string QIRIdNo = fldQIRIdNo.Text;
    SPQuery query = new SPQuery();
    query.Query = "<Where><Eq><FieldRef Name='fldQIRIdNo' /><Value Type='Text'>" + QIRIdNo + "</Value></Eq></Where>";
    SPListItemCollection itemcoll = list.GetItems(query);
    Please help me to fix it. 

    Hi Mario,
    Thanks a lot for your reply.
    query.Query = "<Where><Eq><FieldRef Name='fldQIRIdNo' /><Value Type='Text'>"
    + QIRIdNo + "
    in this CAML query i have indexed my field "fldQIRIdNo". Now i have more then 5000 items in list, and
    iam able to get my list item data without any error.
    Please let me know if my action is wrong.

  • Query to findout list of concurrent requests which is consuming somuch load

    Hi,
    Can anyone please send me query to get list of concurrent processes which is consuming too much LOAD on server.
    Thanks.

    managed to find a good link
    http://download.oracle.com/docs/cd/A60725_05/html/comnls/us/fnd/index.htm

  • To get the list of queries in which a particular variable is used - urgent

    Hi Friends,
    I have a list of variables which were used in some queries, now I need to know list of queries in which the given variable is used.
    for example: There is a variable called ZVBASMNT and used in some queries, I want to get the names of the queries in which it was used.
    please give some short method for this, if there is any table or Tcode for this please provide, its bit urgent.
    Thanks & points will be given for the helpful answer
    Regards...
    Ganesh

    Dear Ganesh,
    Yes, You can find.
    Goto Metadata Repository in RSA1.
    Click on Query
    Selct / Click on a Query which uses your variable ZVACITY
    Click on your variable
    Just observe the USED BY list.
    Regards,
    Ram.

  • BI Statistics -- Need to display list of Queries with query counter

    Hi All,
    I am using the the infoobject
    0TCTBISBOBJ (BI Application Object)  - for to get the list of queries inthe system.
    I am also restricting the infoobject 0TCTBISOTYP(BI Application Object Type)-  to ELEM (Query) inthe filter area.
    I loaded load master data for 0TCTBWOBJCT_ATTR and 0TCTBWOBJCT_TEXT.
    The PROBLEM is  0TCTBISBOBJ (BI Application Object) is not only displaying queries but all the other elements like navigational attributes and some junk values like
    '$ABSEMA0
    '$VIRTUAL-000001
    Please help me isolate just queries for my display.
    Thanks,
    HM

    HI,
    Your query setup is correct, please check Note 936519 - Duplicate Records while loading 0TCTBWOBJCT master data, and many others.
    I have customers running stack 11 & 12 and had to apply dozens of notes to get TCT 7.0 to work properly. And even now about 3 notes per week are being released.
    Regards Patrick Rieken.

  • To get list of Structure, CKF and RKF where used in query

    Hi All,
    We are going to migrate the queries from BW.3.5 to BI 7.0.
    Our aim  is to get list of Structure, CKF and RKF that are being used in the Info provider along with Queries of these Structure ,RKF's and CKF' s .Is there any way
    to get the where used in query.
    Thanks,
    Mohan

    It's been discussed so many times: Check these forums>>
    http://scn.sap.com/thread/2029042
    BEx metadata tables - how to list Query/Chars/KFs
    Rgds..
    Shambhu

  • Search Results Query Text - Get all data, Exclude all list data except one

    Hi Experts,
    I have a situation wherein in the global search of our internal site, we have to display all results & restrict any list item except one list. Earlier we had restricted /Lists/ & People to be displayed in the results.
    But in the new search results I have to display results from only one list along with other results (documents, sites, pages etc).
    Below is the original query text entered in the Search Results Query Text editor
    {searchboxquery} -contentclass:STS_List_Links  
    -filename:allitems.aspx  -Path:/articles/Pages/default.aspx
    -filename:DispForm.aspx  -Path:/Lists/ -Path:person.aspx
    I have tried various different queries with AND, OR operator. I have researched other blogs, sites over google. But unsuccessful. I am sure this is not a rare requirement. Need your expert help.
    I have tried this query also...
    {searchboxquery} (-filename:allitems.aspx -Path:/articles/Pages/ -Path:/Lists/ -Path:/PublishingImages/) OR
    (+(+Path: /Lists/ArticleContent/ AND +filename:*.aspx) AND
    -(-Path: */Lists/* OR -filename:*.aspx))
    Vighnesh Bendre
    MCTS
    http://markviky.blogspot.com

    Vighnesh,
    You should have success using the following:
    {searchboxquery} -contentclass:STS_List_Links -filename:allitems.aspx  -Path:/articles/Pages/default.aspx -Path:person.aspx ((-filename:DispForm.aspx  -Path:/Lists/) OR Path:/Lists/ArticleContent/)
    Two things from your original query were excluding list items from your results, your exclusion of file
    DispForm.aspx and path Lists.  By using "OR" in the above query, we're creating an exception to also allow items under
    Lists/ArticleContent to be included in the results.

Maybe you are looking for