SQL being run by a Session

DB version: 10.2.0.4

To get the SQL code running in a session, I usually get the SQL_ID v$ session for the scheman in question
select sql_id from v$session where schemaname = 'HR'
Then, I run
select sql_Text from v$sql where sql_id = 
But sometimes the SQL_ID will be null for the sessions. So, I would like to know if there is a better way to get the SQL being run by a session now.

Dear Tom,

Alternatively, you can join the fixed views together (v$ sql and v$ session).

Can you please give an example of your statement on the SQL_ID null?

Kind regards.

Ogan

Tags: Database

Similar Questions

  • Error, you must be an administrator to run a console session using SFC

    Original title: vista administor

    have windows vista Home premium and it may seem silly, but how to administer privileges. Am the only one on the laptop so I thought I got them somehow, but not so much that when I tried to invite her command of my I get the message: you must be anrat administor running a console session in order to use sfc. I checked that I really am an administrator and I think I did it to accounts but I'm puzzle with this

    Hello

    You right-click on command prompt and select run as Administrator:

    "How to use the System File Checker tool to fix the files on system missing or corrupted on Windows Vista or Windows 7"

    http://support.Microsoft.com/kb/929833

    Use the (SFC.exe) System File Checker tool to determine which file is causing the problem and then replace the file. To do this, follow these steps:

    1. Open an elevated command prompt. To do this, click Start, click principally made programs, Accessories, right-click guest, and then click run as administrator. If you are prompted for an administrator password or a confirmation, type the password, or click allow.
    2. Type the following command and press ENTER:
      sfc/scannow

      The sfc/scannow command analyzes all protected system files and replaces incorrect versions with appropriate Microsoft versions.

    See you soon.

  • Error when you try to install QuickTime: another installation is being run-cannot install new software

    Original title: another installation is being run-canot install new software.

    Remember - this is a public forum so never post private information such as numbers of mail or telephone!

    Ideas: I can't identify what software is running. I had this problem in recent weeks. It cannot install QuickTime.
    Thank you

    • You have problems with programs
    • Error messages
    • Recent changes to your computer
    • What you have already tried to solve the problem

    Hi marvinsadovsky,

    ·        What is the exact error you get when you try to install QuickTime?

    ·        You are able to install any other application?

    You try to install QuickTime by starting the computer in a clean boot state, because some background programs may interfere with the installation process. To put the computer in a clean boot state, follow the link below.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

    http://support.Microsoft.com/kb/929135

    Note: When you are finished troubleshooting, follow step 7 article to start on normal startup.

    Hope this information is useful.

    Amrita M

    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Accept the user SQL and run batch

    Hi all

    I want to invite the user to enter their SQL and run it during the execution of a batch file.

    Results (after the running .bat file):

    Press any key to enter your sql

    -will be here sql user input

    You SQL statement has been executed successfully.

    Try:

    SET /P DB = [promptDBname]

    SET /P USER = [promptuserName]

    SET /P PWD = [promptPass]

    SET /P sqlText = [promptSQL]

    sqlText %Echo% > script.sql

    sqlplus %USER%/%PWD%@%DB% @script.sql

    Perversion!

    ----

    Ramin Hashimzade

  • Script Sql to run in the background

    Hi guys,.

    I will carry out two unix machine sql scripts by connecting through sqlplus in two sessions of PuTTY, I need to run the scripts background is there a way to run outside the sh script execution.

    SQL > @test.sql

    .

    .

    .

    Another session

    SQL > @test1.sql

    .

    .

    .

    actutally I need to run the sql in the background scripts so that my putty session will not cut

    Assuming that this is really what you want to do, use screen sessions.

    This puts the interactive session of ATS in the background, allowing you to reconnect to the it (another putty session, or of the same) to a later date to check the results manually intervene, etc.

    Install the screen on the server as root:

    yum-y install screen

    As the launch of PuTTY user session screen:

    screen

    Then start your session of sqlplus, script execution, etc.-, then press ALT-D to disconnect from the session.

    Start at any number of additional screen sessions.

    To list the sessions:

    Screen - ls

    To join your putty for a screen session session:

    session - dr

    Lose your PuTTY connection does not screen sessions you started. You can go home, in the Office VPN, mastic fire upwards and reconnect to sessions of your screen.

  • PL/SQL to run the exe with the DB settings

    Hi all

    I have a little problem.

    I'm in the need to write that all connection, disconnection and connection fail data to the Windows application log. To do this, I already tried various solutions, but with my configuration (EE Oracle 10.2.0.4) and Windows Server 2003 R2 X 64 the only possible solution is (apparently) the following.

    I create a Table with the information I need:

    --------------------------------------

    CREATE TABLE logonaudittable
    (
    event VARCHAR2 (15).
    SID NUMBER,
    series # NUMBER,
    time DATE,
    name VARCHAR2 (30),
    osuserid VARCHAR2 (30),
    MachineName VARCHAR2 (64)
    )
    /
    --------------------------------------

    I have create a trigger for the connection data, one for logging for the logon fails:

    ------------------------------------------------

    LOGON trigger.

    Database of logonauditing AFTER logon ON CREATE OR REPLACE TRIGGER
    DECLARE
    MachineName VARCHAR2 (64);
    osuserid VARCHAR2 (30);
    v_sid NUMBER (10);
    v_serial NUMBER (10);

    CURSOR c1 IS
    SELECT sid, serial #, osuser, machine
    FROM v$ session WHERE audsid = userenv ('sessionid');
    BEGIN
    OPEN c1;
    EXTRACT the c1 IN v_sid, v_serial, osuserid, machinename;

    INSERT INTO logonaudittable VALUES ('CONNECT', v_sid, v_serial, sysdate,
    user, osuserid, machinename);

    CLOSE c1;
    END;
    /

    -----------------------------------------------

    Logoff trigger

    CREATE OR REPLACE TRIGGER logoffauditing
    BEFORE logoff ON database
    DECLARE
    MachineName VARCHAR2 (64);
    osuserid VARCHAR2 (30);
    v_sid NUMBER (10);
    v_serial NUMBER (10);

    CURSOR c1 IS
    SELECT sid, serial #, osuser, machine
    FROM v$ session WHERE audsid = userenv ('sessionid');
    BEGIN
    OPEN c1;
    EXTRACT the c1 IN v_sid, v_serial, osuserid, machinename;

    INSERT INTO logonaudittable VALUES ('LOGOUT', v_sid, v_serial, sysdate,
    user, osuserid, machinename);

    CLOSE c1;
    END;
    /

    -------------------------------------------------------

    Logon trigger FAILS

    CREATE OR REPLACE TRIGGER logonfailauditing
    AFTER ON SERVERERROR database
    DECLARE
    MachineName VARCHAR2 (64);
    osuserid VARCHAR2 (30);
    v_sid NUMBER (10);
    v_serial NUMBER (10);

    CURSOR c1 IS
    SELECT sid, serial #, osuser, machine
    FROM v$ session WHERE audsid = userenv ('sessionid');
    BEGIN
    IF (IS_SERVERERROR (1017)) THEN
    OPEN c1;
    EXTRACT the c1 IN v_sid, v_serial, osuserid, machinename;
    INSERT INTO logonaudittable VALUES ('FAILLOGON', v_sid, v_serial, sysdate,
    user, osuserid, machinename);
    CLOSE c1;
    END IF;
    END;
    /

    -------------------------------------------

    The I create a trigger that starts each time something is written on the table.
    This trigger must start an EXE file which writes the last data written on the table in the Windows application log.

    So I need a trigger that executes my WRITELOG. EXE file adding parameters. For example:

    Run WRITELOG. Event time username sid EXE

    So my program will write a journal in Windows with these data:

    Event: opening of SESSION
    SID: 2938473
    Time: 12/12/2011 11:45:32
    User name: Scott

    And so on.

    I already have the program that does this, I need to run the program with the right data directly from trigger or procedure performed by my trigger.

    Hope that I was clear and REALLY hope that someone can help me!

    Thanks to you all!

    So practically I should create a job something like this:

    BEGIN
    () dbms_scheduler.create_job
    job_name-online "CONNECTION."
    job_type-online "EXECUTABLE."
    job_action => ' c:\yourdirectory\FILE. LOGON EXE ' | v_sid | » '|| v_serial | » '|| to_char(sysdate,'MM/DD/YYYY') | » '|| the user | » '|| osuserid | » '|| MachineName |';
    number_of_arguments-online 1
    start_date => SYSTIMESTAMP,
    enabled-FALSE, online
    comments => ' SQL * Loader jobs Demo');
    END;
    /

    and then I need to start this work every time that the LOGON trigger fires and it must be the trigger that inserts into the work, the arguments v_sid, v_serial, etc..

    ... I don't know how I can do this. What I need to create a procedure that creates jobs and the procedure is executed by the trigger? and how do you know the procedure to create the job with the data provided by the trigger. Sorry I ask much for the help, but I need this thing made in a time which is not compatible with me studying how to do it by myself. I will look at it, I want to know exactly how these things work, but now I need to speed things up a bit!

    Thank you for all the valuable assistance tfor!

  • trying to get used to sql * more running and creating a simple procedure

    Hello all;

    I'm getting used to sql * more after using for a while using pl/sql developer.

    I am trying to create a simple procedure and run it. See my procedure below
    create or replace procedure test(t in varchar2(200), limit in number(30))
    begin
    select tbl_report.id from tbl_report where tbl_report.id like '|| t ||%' and rownum <= limit;
    end test;
    and then I type in run hr.test ("J", 10); to run this and then press ENTER, and it does nothing. How can I run and create a simple procedure in sql * more

    Hello

    In addition to all the good points, others have done:

    When you issue a SELECT statement in SQL * Plus (or any other front end) two things happen:
    (1) a result set, containing the results of your query, is produced, and
    (2) this result set is displayed.
    Given that these two things are always done together, it is easy to forget that they are two different things.
    In PL/SQL, you must explicitly do something to catch the result set, and you must explicitly do something else to view it (if you want to display it).

    A simple way to get the result set is to use a cursor FOR loop, to extract a line at a time and run code with this line in a record variable (called the country in the example below).
    View the results is to call dbms_output.put_line.

    Here is an example:

    CREATE OR REPLACE PROCEDURE     test
    (       t       IN      VARCHAR2
    ,     lmt      IN     NUMBER          -- LIMIT is an Oracle keyword; best not to use it as a variable name
    )
    IS
    BEGIN
        FOR  country  IN ( SELECT  country_name
                          FROM    hr.countries
                     WHERE   country_name     LIKE t || '%'
                     AND     ROWNUM          <= lmt
                   )
        LOOP
            dbms_output.put_line (  country.country_name
                        || ' = country_name'
                        );
        END LOOP;
    END test;
    /
    SHOW ERRORS
    

    You can use variables, such as t and lmt, in the query without using dynamic SQL, as long as the variables do not have the same names as the columns in the table. In this case, t and lmt are good names; country_name or region_id wouldn't. (In fact, t is a reputable insofar as it cannot be confused with a column in the table of the country. T is not a good reputation in the sense that it does not give much information about what contains the variable, or how it is used. Why not call the variable target_name or name_a_trouver?

    You can run the SQL procedure * more like this:

    SET     SERVEROUTPUT     ON
    
    EXEC  test ('I', 2);
    

    If you issue the SET SERVEROUTPUT ON command, then you will not see the output of dbms_output. You must only issue the command SET SERVEROUTPUT ON once per session, but nothing bad happens if you do it more than once.

    When I ran the procedure as stated above, I got this output:

    Israel = country_name
    India = country_name
    

    Notice that "The Italy" does not appear, because lmt has 2.

    Do not create your own procedures, tables or other objects in the HR schema, or among all the other patterns created by Oracle. Create your own schema and create procedures and other objects in it.

  • I want to write a PL/SQL script to kill a session.

    I wrote a script for which considers a SID as input requests, V$ SESSION and verifies that the SID that you are trying to kill is not a background process, not SYS or SYSTEM and is the same user that you are. Once it checks these things, it issues an alter system kill session.

    If I create the SYS account service is very good. But I don't want end users to be able to run this script on the SYS account.
    I have another schema with privileges DBA I would love to own the PL/SQL script.

    Here's the rub, because the function queries session$ v, apparently not I can compile like no other function than to the SYS.
    If anyone can confirm this?

    I know that in PL/SQL, I can't access an object through a ROLE, I have been granted a SELECT on the object if I want to refer to it.
    But, if I'm in the SYS schema, I can't grant SELECT on v$ session to any account, because it's a dynamic performance view.

    Does anyone have a suggestion?

    Thank you

    I can't grant SELECT on v$ session to any account, because it's a dynamic performance view.

    Use V_$ SESSION

  • Exercise enough free SQL Server running?

    I took a course SQL and the pattern of their installation program has been a (sitting at the computer) User Management Studio connection, which in turn connects to the SQL translator, which is attached with DBMS SQL Server, which is connected to the SQL Server database.

    All I want to do a few exercises query, and I wonder if the free SQL Server Express development would be sufficient.  I had a whole CD of SQL files, including some set up tables for questioning.  I would like to be placed on my home computer, which runs Windows 7 Professional 64 bit.

    Hello

    The question you posted would be better suited in the MSDN Forums. I would recommend posting your query in the MSDN Forums:

    http://social.msdn.Microsoft.com/forums/en/category/SQLServer

  • Load plans being run/Scheduling command line ODI

    Here's our scenario

    (1) we have a several load plans that move on different schedules. These changes of schedules each month. For example, we have a defined business window (usually end of month process) which changes from month to month. This business window set is stored in a custom table.

    (2) in this window, we run load is considering either once a day or every hour or just only once in this window, etc.

    I looked in the Plan charge hourly, but that wasn't our goal because of the complexity in date, time, and frequency. Also, we do not have any third party planner. I think to launch Plans to load a command line (. / startloadplan.sh) using a programming language (PL/SQL or Unix script)

    However, I am struggling to find how can I reach annex to a charge by command line plan? for example if I want to execute the plan to charge for the next 3 days every hour, how can say I do it through command line?

    Any suggestions would be very helpful.

    You can simply create a schedule like that unfortunately. The schedule should be attached to the repository, then the agent must be updated.

    What you could do, is add a script using the SDK of ODI. Chantal Mangano wrote a great blog about this (ODI11g): http://dwteam.in/scheduling-in-odi-using-sdk/

  • Dynamic Action run PL/SQL Code runs is not after 4.2.5 upgrade

    APEX 4.2.4 to 4.2.5 11.2 database upgrade

    I have a button to click on DA who owns shares run of PL/SQL Code and update point who worked in version 4.2.4 which is no longer running after the 4.2.5 patch.

    The PL/SQL procedure has been tested autonomous and it runs correctly.

    I tested him DA is actually shot on the click event by adding an alert "DA xxxx pulled" action before the execution of work of PL/SQL action and action alert.

    There is also a similar on DA click which makes the action opposite to the DA problem and it works both are configured in the same way:

    Static DA, run Code PL/SQL - check waiting for result, and not repress with the same Submit and return items.

    Any ideas on a possible cause/solution much appreciated

    Fixed it, the question was the Page elements of return of goods on the action of PL/SQL Code:

    If the target element was empty the action failed, by adding a value in the database through a normal SQL insert then the insert DA completed successfully.

    Removing Page elements at the point of return of the action of PL/SQL and together action update the target element after the DA fires in all scenarios.

    But thanks for the lead

  • How to get the SQL query running of af: search?

    I use JDeveloper 11.1.2.3.0. I have a page where I've set up an af:query and an array of result. The problem is that I can't get the exact query that is used during the execution of this component in a managed bean method. Is it possible to get the query string that is run within the af: query?

    Thank you

    Hello

    Method of the ViewObject getQuery() returns what you need;

    You can replace the executeQueryForCollection(), and prior to calling super, you can print the result of getQuery() method:

    public void executeQueryForCollection (rowset Object,

    Object [] params,

    {int noUserParams)

    System.out.println ("SQL =" + getQuery());

    call the super method here...

    }

  • Script SQL Developer runs all the lines

    I have a group of scripts that I want to execute in the order since a main script.  I created a file referencing these scripts as follows below.  My problem is that when I run this script (via F5 or another script referencing it), it runs only the first line and stops.  I have excluded questions with my references to file by changing the order - always the first runs and stops.  I have tried such as displayed below and with a semicolon; to separate each command.  I have scoured the web and can not find any reason why it does not work.  Each of the scripts listed below contains multiple statements separated by a; that wraps a file to a NAS where he is picked up by our external file transfer program.  It all works properly - the only thing that I have problems with using 1 script to call several files and run them in order.

    Any help is greatly appreciated!

    @EMSTATUS.sql

    @EMPLOYEE.sql

    @HREMPUSF.sql

    @HRHISTORY.sql

    @HRSUPER.sql

    @JOBCLASS.sql

    @JOBCODE.sql

    @PAACTREAS.sql

    @PAEMPLOYEE.sql

    @PAEMPPOS.sql

    @PCODES.sql

    @PCODESDTL.sql

    @PERSACTHST.sql

    @PRDISTRIB.sql

    @PRPAYCODE.sql

    @PSGRELATE.sql

    @REVIEW.sql

    Hello

    Note You can place in the path: Tools-> preferences-> database-> spreadsheet-> "path select default to search scripts"


    I tried the following:

    c:\tmp\calltwoscripts. SQL

    set echo on

    @zone.sql

    @ztwo.sql

    Select 'done' double.

    c:\tmp\zone. SQL:

    Select 'one' double;

    c:\tmp\ztwo. SQL:

    Select 'two' SQL;

    executed in a worksheet:

    @c:/tmp/calltwoscripts.sql

    Output:

    > @zone.sql

    > select "one" of the double

    'A '.

    -----

    one

    > @ztwo.sql

    > Select "both" of the double

    "TWO".

    -----

    two

    > select 'done' double

    'DONE '.

    ----------

    Finish

    The things that could go wrong:

    Your scripts could end with "quit".

    Paths can mingle: try (not @) and full of paths.

    You could hit a code issue, the spreadsheet does not recover-in which case you should get the output on the command line and or Page logging of messages in the view.

    Turloch

    SQLDeveloper - team

    http://www.thatjeffsmith.com/archive/2012/06/how-to-collect-Debug-Info-for-Oracle-SQL-Developer/

    http://totierne.blogspot.co.UK/2013/07/user-check-on-sqldeveloper-worksheet.html

  • sql statements run correctly

    Hello

    It is a question of certification.

    Question: 3
    Examine the structure of the table of PROGRAMS:
    Name Null? Type
    ---------- ------------- ---------------
    PROG_ID NOT NULL NUMBER (3)
    PROG_COST NUMBER (8.2)
    START_DATE DATE NULL NOT
    END_DATE DATE
    The two SQL statements would be run successfully? (Choose two.)
    A. SELECT NVL (ADD_MONTHS(END_DATE,1), SYSDATE) OF programs;
    B. SELECT TO_DATE (NVL (SYSDATE-END_DATE, SYSDATE)) OF programs;
    C. SELECT NVL (MONTHS_BETWEEN (start_date, end_date), 'Ongoing') OF programs;
    D. SELECT NVL (TO_CHAR (MONTHS_BETWEEN (start_date, end_date)), 'Ongoing') OF
    programs;

    Answers: A, D

    My question is:
    If A and D are correct woud B and C run successfully also right?

    Please specify.

    What? You are able to do this in your test db?
    You get an error for B and C for this reason - the expressions in the two queries will assess a number. B trying to do a TO_DATE on a NUMBER, and C tries to substitute a VARCHAR2 string where a NUMBER is expected.

  • SQL that runs for a long time

    Hi guys,.

    How to find the start time of the SQL statements that run for a long time and who are running in the system.

    Hello

    If they are long launched, you can take a look at the view V$ SESSION_LONGOPS. There is a column of start_time.

    Herald tiomela
    http://htendam.WordPress.com

Maybe you are looking for