What is this SQL give us

I am trying to understand the SQL...Can anyone tell me what is SQL do...
SELECT *
  FROM foms.inspection_task m
WHERE type_check_code = 'P'
   AND
EXISTS (
          SELECT 0
            FROM foms.inspection_task X
           WHERE X.TRIPPLANKEY = m.TRIPPLANKEY
             AND X.dfl_sequence = m.dfl_sequence
             AND X.ROWID !=M.ROWID)

Hi,
SELECT *                 -- Display all columns
  FROM foms.inspection_task m     -- from this table
WHERE type_check_code = 'P'     -- with this condition
AND
EXISTS (               -- only if there's a row
          SELECT 0
            FROM foms.inspection_task X          -- in the same table
           WHERE X.TRIPPLANKEY = m.TRIPPLANKEY     -- with the same tripplankey
             AND X.dfl_sequence = m.dfl_sequence  -- and the same dfl_sequence
             AND X.ROWID !=M.ROWID)          -- but a different ROWIDROWID is unique for every row, so the effect is to pick the row "only if there's a *different* row in the same table ..."

Similar Messages

  • What is this sql that is always in my top 10

    Does anybody know why this sql is always in my top 10 on the top activity page?
    SELECT VALUE
    FROM V$SESSION_FIX_CONTROL
    WHERE BUGNO = :B1 AND SESSION_ID = USERENV('SID')
    I started seeing this when we moved to 11gR2. I just want to understand what this is and why it takes up 10% of my resources.
    Thanks, Keith

    Thanks for your response Hans.
    Yes this is question best framed to support. It is just a PITA to get something simple into support. It is akin to going to the dentist. There are so many required boxes which are often irrelevant so you start making up BS just to submit the tar, SR. Then the SR goes to level 1 where someone tries to help you. It'll take them 10 days to understand that the SQL in question is an internal SQL statement submitted inside of Oracle. They will be asking me schema design questions or some other irrelevant stuff. Might as well ask me how I liked the weather. Sorry to rant, so I'll stop.
    Keith :-)

  • What is this SQL Tuning Advisor's Advice means

    HI ,
    I am Tuning a query wit hthe help of ORACLE 10 g 's SQL Tuning Advisor.I got the following recommendation .
    **Consider removing the disconnected table or view from this statement or add a join condition which refers to it.**
    I didn't understand what does this mean.
    Can anyone please help me
    Thanks,
    Pramod.
    Edited by: Pramod Garre on Jul 15, 2009 6:20 AM

    Simply saying if i apply that profile i will get Good plan.But I want to change the SQL itself rather than applying profile.in that case what can be done.Automatic SQL Tuning deals with this problem with its SQL Profiling capability. The Automatic Tuning Optimizer creates a profile of the SQL statement called a SQL Profile, consisting of auxiliary statistics specific to that statement. The query optimizer under normal mode makes estimates about cardinality, selectivity, and cost that can sometimes be off by a significant amount resulting in poor execution plans. SQL Profile addresses this problem by collecting additional information using sampling and partial execution techniques to verify and, if necessary, adjust these estimates.During SQL Profiling, the Automatic Tuning Optimizer also uses execution history information of the SQL statement to appropriately set optimizer parameter settings, such as changing the OPTIMIZER_MODE initialization parameter setting from ALL_ROWS to FIRST_ROWS for that SQL statement.
    If you want to change the SQL, You can re-write the SQL and evaluate the Performance recommendations SQL tuning Advisor.

  • What does this SQL Exception mean?

    Well I told you guys I'd be back with more questions. The database is now connected and my add User feature is working fine. I am however, receiving an SQL Exception when I try to update or delete. Here's the exception:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6183)
         at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2489)
         at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:329)
         at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:279)
         at UserDM.updateUser(UserDM.java:187)
         at User.updateUser(User.java:271)
         at UserUI.invokeUpdate(UserUI.java:296)
         at UserUI.actionPerformed(UserUI.java:236)
         at java.awt.Button.processActionEvent(Button.java:324)
         at java.awt.Button.processEvent(Button.java:297)
         at java.awt.Component.dispatchEventImpl(Component.java:2588)
         at java.awt.Component.dispatchEvent(Component.java:2492)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:334)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:126)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:93)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:88)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:80)
    java.sql.SQLException: Invalid handle
         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6198)
         at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2489)
         at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:329)
         at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:244)
         at UserDM.populateUser(UserDM.java:130)
         at User.buildUserVector(User.java:301)
         at User.updateUser(User.java:277)
         at UserUI.invokeUpdate(UserUI.java:296)
         at UserUI.actionPerformed(UserUI.java:236)
         at java.awt.Button.processActionEvent(Button.java:324)
         at java.awt.Button.processEvent(Button.java:297)
         at java.awt.Component.dispatchEventImpl(Component.java:2588)
         at java.awt.Component.dispatchEvent(Component.java:2492)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:334)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:126)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:93)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:88)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:80)Here is the method:
         // method to update info for a user in the database
        public static void updateUser(User aUser) throws SQLException
            String query1 = "UPDATE Users SET LastName = " + "'" + aUser.getUserLastName() + "'" + " WHERE Alias = " + aUser.getUserAlias();
              String query2 = "UPDATE Users SET FirstName = " + "'" + aUser.getUserFirstName() + "'" + " WHERE Alias = " + aUser.getUserAlias();
              String query3 = "UPDATE Users SET MiddleInitial = " + "'" + aUser.getUserMiddleInitial() + "'" + " WHERE Alias = " + aUser.getUserAlias();
              String query4 = "UPDATE Users SET Alias = " + "'" + aUser.getUserAlias() + "'" + " WHERE Alias = " + aUser.getUserAlias();
              String query5 = "UPDATE Users SET Password = " + "'" + aUser.getUserPassword() + "'" + " WHERE Alias = " + aUser.getUserAlias();
              String query6 = "UPDATE Users SET Role = " + "'" + aUser.getUserRole() + "'" + " WHERE Alias = " + aUser.getUserAlias();
              String query7 = "UPDATE Users SET Rights = " + "'" + aUser.getUserType() + "'" + " WHERE Alias = " + aUser.getUserAlias();
            Statement statement = connection.createStatement();
              statement.executeUpdate(query1);
            statement.executeUpdate(query2);
            statement.executeUpdate(query3);
            statement.executeUpdate(query4);
            statement.executeUpdate(query5);
            statement.executeUpdate(query6);
            statement.executeUpdate(query7);
              userList.removeAll();
               if( userRS !=null)
               while( userRS.next() )
                         aLastName = userRS.getString(1);
                         userList.add(aLastName);
            statement.close();
              close();
              open();
        }The reason for the multiple queries is that it's just easier with my editor than trying to concatenate to new lines. I still get the same exception with just one query.
    Thanks,
    Shawn

    I changed it to the prepared statement. As for the question about the Alias, I don't know why that would have to be in parentheses since it's a field in the table. I double checked all the table and field names with the one in the code, they are in sync. Here's my new method:
         // method to update info for a user in the database
        public static void updateUser(User aUser) throws SQLException
         String preparedSQL = "UPDATE Users SET " +
                                   "LastName = ?, FirstName = ?, MiddleInitial = ?, Alias = ?, Password = ?, Role = ?, Rights = ?" +
                                  "WHERE Alias = ?";
         PreparedStatement ps = connection.prepareStatement(preparedSQL);
         ps.setString(1, aUser.getUserLastName());
         ps.setString(2, aUser.getUserFirstName());
         ps.setString(3, aUser.getUserMiddleInitial());
         ps.setString(4, aUser.getUserAlias());
         ps.setString(5, aUser.getUserPassword());
         ps.setString(6, aUser.getUserRole());
         ps.setString(7, aUser.getUserType());
         ps.setString(8, aUser.getUserAlias());
         ps.executeUpdate();
    }Here are the exceptions I'm getting now:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect
    java.sql.SQLException: Invalid handle
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Pa_RaM006WHERE Alias = Pa_RaM007'.
    java.sql.SQLException: Invalid handle
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Pa_RaM006WHERE Alias = Pa_RaM007'.
    java.sql.SQLException: Invalid handle
    java.lang.ArrayIndexOutOfBoundsException: 7
    java.sql.SQLException: Invalid handle
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Pa_RaM006WHERE Alias = Pa_RaM007'.
    java.sql.SQLException: Invalid handleWhat could the missing operator be for the Alias? I've tried using the message aUser.getUserAlias instead of the ?, but it gives the same exception.
    I do not have it set up for CONCUR_UPDATABLE, it that necessary for this application? I also heard that a permission statement is supposed to be added to the java.policy file, any input on this?
    Thanks!
    Shawn

  • What is this SQL trick

    Can someone help me how do i get a result in one row :
    Original Table Looks like below where C1,c2,c3,c4,c5 are columns and 1,2,3,4,A are the rows
    C1 | C2 | C3 | C4| C5
    1 2 3 4 A
    1 2 3 4 B
    1 2 3 4 C
    I need output using SQL as
    C1 | C2 | C3 | C4| C5
    1 2 3 4 ABC
    thanks in advance
    Murali

    Hola Murali and Christo la
    solucion fue la siguiente em mi caso
    particular. Espero que les sirva:
    Nota: Esta solucion es para mas
    columnas(Quitar Cn-2 y Cn-1)
    Donde:
    LO_EDIFICIO es C1
    LO_PISO es C2 LO_ZONA es C3 LO_CVE_EMP es C4
    LO_CC_O_CATEGORIA es Cn-2
    LO_NO_ART es Cn-1
    FALLO_POR es C5
    create table lec_opt_rechazados(
    LO_EDIFICIO VARCHAR2(10),
    LO_PISO VARCHAR2(10),
    LO_ZONA VARCHAR2(10),
    LO_CVE_EMP VARCHAR2(10),
    LO_CC_O_CATEGORIA VARCHAR2(10),
    LO_NO_ART VARCHAR2(20),
    FALLO_POR VARCHAR2(100))
    TABLESPACE FNDPRO_TMP;
    -- Crea Vistas --
    Rem ********* Fallo por Edificio ****************
    create or replace view FXE as
    select
    LO_EDIFICIO ,
    LO_PISO ,
    LO_ZONA ,
    LO_CVE_EMP ,
    LO_CC_O_CATEGORIA ,
    LO_NO_ART ,
    decode(fallo_por,'Edif','Edif',null) FXE
    from lec_opt_rechazados;
    Rem ********* Fallo por Piso *********************
    create or replace view FXP as
    select
    LO_EDIFICIO ,
    LO_PISO ,
    LO_ZONA ,
    LO_CVE_EMP ,
    LO_CC_O_CATEGORIA ,
    LO_NO_ART ,
    decode(fallo_por,'Piso','Piso',null) FXP
    from lec_opt_rechazados;
    Rem ********* Fallo por Zona *********************
    create or replace view FXZ as
    select
    LO_EDIFICIO ,
    LO_PISO ,
    LO_ZONA ,
    LO_CVE_EMP ,
    LO_CC_O_CATEGORIA ,
    LO_NO_ART ,
    decode(fallo_por,'Zona','Zona',null) FXZ
    from lec_opt_rechazados;
    Rem ********* Fallo por Cve Empleado **************
    create or replace view FXCE as
    select
    LO_EDIFICIO ,
    LO_PISO ,
    LO_ZONA ,
    LO_CVE_EMP ,
    LO_CC_O_CATEGORIA ,
    LO_NO_ART ,
    decode(fallo_por,'Cve Emp','Cve Emp',null) FXCE
    from lec_opt_rechazados;
    Rem ********* Fallo por Centro de Costos o Categoria ********
    create or replace view FXCC as
    select
    LO_EDIFICIO ,
    LO_PISO ,
    LO_ZONA ,
    LO_CVE_EMP ,
    LO_CC_O_CATEGORIA ,
    LO_NO_ART ,
    decode(fallo_por,'CC','CC','Categ','Categ',null) FXCC
    from lec_opt_rechazados;
    Nota: Si C5 tubiera dos valores
    Rem ********* Fallo por Duplicados o repetidos ********
    create or replace view FXD as
    select
    LO_EDIFICIO ,
    LO_PISO ,
    LO_ZONA ,
    LO_CVE_EMP ,
    LO_CC_O_CATEGORIA ,
    LO_NO_ART ,
    decode(fallo_por,'Art Dup','Art Dup',null) FXD
    from lec_opt_rechazados;
    -- Crea Vista General de Rechazados --
    create or replace view V_LO_RECHAZADOS AS
    select
    A.LO_EDIFICIO LO_EDIFICIO ,
    A.LO_PISO LO_PISO ,
    A.LO_ZONA LO_ZONA ,
    A.LO_CVE_EMP LO_CVE_EMP ,
    A.LO_CC_O_CATEGORIA LO_CC_O_CATEGORIA ,
    A.LO_NO_ART LO_NO_ART ,
    max(fxe| |','| |fxp| |','| |fxz| |','| |fxce| |','| |fxcc| |','| |fxd) FALLO_POR
    from
    fxe a,fxp b, fxz c, fxce d,fxcc e, fxd f
    where
    a.lo_no_art = b.lo_no_art(+) and
    b.lo_no_art = c.lo_no_art(+) and
    c.lo_no_art = d.lo_no_art(+) and
    d.lo_no_art = e.lo_no_art(+) and
    e.lo_no_art = f.lo_no_art(+)
    group by
    A.LO_EDIFICIO ,
    A.LO_PISO ,
    A.LO_ZONA ,
    A.LO_CVE_EMP ,
    A.LO_CC_O_CATEGORIA ,
    A.LO_NO_ART ;
    Atte: Cualquier duda o aclaracion por favor
    de enviarla a [email protected]
    Oscar Molina Mexico D. F.
    null

  • What's wrong with this SQL?

    what's wrong with this SQL?
    Posted: Jan 16, 2007 9:35 AM Reply
    Hi, everyone:
    when I insert into table, i use the fellowing SQL:
    INSERT INTO xhealthcall_script_data
    (XHC_CALL_ENDED, XHC_SWITCH_PORT, XHC_SCRIPT_ID, XHC_FAX_SPECIFIED)
    VALUES (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT, HH_SCRIPT,'N'
    FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE' UNION
    SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT, HH_SCRIPT,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE');
    I always got an error like;
    VALUES (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS'), HH_SWITCHPORT,
    ERROR at line 3:
    ORA-00936: missing expression
    but I can't find anything wrong, who can tell me why?
    thank you so much in advance
    mpowel01
    Posts: 1,516
    Registered: 12/7/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:38 AM in response to: jerrygreat Reply
    For starters, an insert select does not have a values clause.
    HTH -- Mark D Powell --
    PP
    Posts: 41
    From: q
    Registered: 8/10/06
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:48 AM in response to: mpowel01 Reply
    Even I see "missing VALUES" as the only error
    Eric H
    Posts: 2,822
    Registered: 10/15/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:54 AM in response to: jerrygreat Reply
    ...and why are you doing a UNION on the exact same two queries?
    (SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS') ,HH_SWITCHPORT ,HH_SCRIPT ,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE' UNION SELECT TO_DATE(HH_END_DATE||' '||HH_END_TIME,'MM/DD/YY HH24:MI:SS') ,HH_SWITCHPORT ,HH_SCRIPT ,'N' FROM tmp_healthhit_load WHERE HH_SCRIPT !='BROCHURE');
    jerrygreat
    Posts: 8
    Registered: 1/3/07
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:55 AM in response to: mpowel01 Reply
    Hi,
    thank you for your answer, but the problem is, if I deleted "values" as you pointed out, and then execute it again, I got error like "ERROR at line 3:
    ORA-03113: end-of-file on communication channel", and I was then disconnected with server, I have to relogin SQLplus, and do everything from beganing.
    so what 's wrong caused disconnection, I can't find any triggers related. it is so wired?
    I wonder if anyone can help me about this.
    thank you very much
    jerry
    yingkuan
    Posts: 1,801
    From: San Jose, CA
    Registered: 10/8/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 9:59 AM in response to: jerrygreat Reply
    Dup Post
    jerrygreat
    Posts: 8
    Registered: 1/3/07
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 10:00 AM in response to: Eric H Reply
    Hi,
    acturlly what I do is debugging a previous developer's scipt for data loading, this script was called by Cron work, but it never can be successfully executed.
    I think he use union for eliminating duplications of rows, I just guess.
    thank you
    jerry
    mpowel01
    Posts: 1,516
    Registered: 12/7/98
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 10:03 AM in response to: yingkuan Reply
    Scratch the VALUES keyword then make sure that the select list matches the column list in number and type.
    1 insert into marktest
    2 (fld1, fld2, fld3, fld4, fld5)
    3* select * from marktest
    UT1 > /
    16 rows created.
    HTH -- Mark D Powell --
    Jagan
    Posts: 41
    From: Hyderabad
    Registered: 7/21/06
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 10:07 AM in response to: jerrygreat Reply
    try this - just paste the code and give me the error- i mean past the entire error as it is if error occurs
    INSERT INTO xhealthcall_script_data
    (xhc_call_ended, xhc_switch_port, xhc_script_id,
    xhc_fax_specified)
    SELECT TO_DATE (hh_end_date || ' ' || hh_end_time, 'MM/DD/YY HH24:MI:SS'),
    hh_switchport, hh_script, 'N'
    FROM tmp_healthhit_load
    WHERE hh_script != 'BROCHURE'
    UNION
    SELECT TO_DATE (hh_end_date || ' ' || hh_end_time, 'MM/DD/YY HH24:MI:SS'),
    hh_switchport, hh_script, 'N'
    FROM tmp_healthhit_load
    WHERE hh_script != 'BROCHURE';
    Regards
    Jagan
    jerrygreat
    Posts: 8
    Registered: 1/3/07
    Re: what's wrong with this SQL?
    Posted: Jan 16, 2007 11:31 AM in response to: Jagan Reply
    Hi, Jagan:
    thank you very much for your answer.
    but when I execute it, I still can get error like:
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    so wired, do you have any ideas?
    thank you very much

    And this one,
    Aother question about SQL?
    I thought I already told him to deal with
    ORA-03113: end-of-file on communication channel
    problem first.
    There's nothing wrong (syntax wise) with the query. (of course when no "value" in the insert)

  • I am suddenly unable to open my pictures in Adobe Photoshop. It gives the following message: The document "Tina-19.jpg" could not be opened. Photoshop cannot open files in the  "Adobe Photoshop JPEG file" format. What does this mean? I have opened my phot

    I am suddenly unable to open my pictures in Adobe Photoshop. It gives the following message: The document “Tina-19.jpg” could not be opened. Photoshop cannot open files in the  “Adobe Photoshop JPEG file” format.
      What does this mean? I have opened my photos in Adobe Photoshop for years and suddenly I get this message and can't open any of my pictures

    JoeLib wrote:
    You type way faster than me Gene.
    Well, not necessarily in this case.
    According to the time stamp, Gene posted his answer a bit over three hours before you did, Joe.
    Gene's post:       Dec 29, 2014 5:54 PM
    Joe's post:          Dec 29, 2014 8:57 PM

  • Every time I fire up my iMac a window pops up saying "Mount notification quit unexpectedly" and it gives me the option to either "Reopen" it or click OK, which gets rid of it. What is this please and how can i stop it?

    Every time I fire up my iMac a window pops up saying "Mount notification quit unexpectedly" and it gives me the option to either "Reopen" it or click OK, which gets rid of it. What is this please and how can i stop it?

    Hopefully this will help you.  Try placing your iPad in recovery mode again.  You may have to try this a few times.
    iOS: Unable to update or restore

  • Whats wrong with this sql statement ??

    Hello all, I am trying to run the below query out of persheet(tanel poder) performance excel chart...but i get below error...db is on 9.2
    what is wrong with this sql statement ?
    http://blog.tanelpoder.com/2008/12/28/performance-visualization-made-easy-perfsheet-20-beta/
    select * from (
    with fsq as (
      select /*+ materialize */
       i.dbid
        , i.instance_name
        , i.instance_number
    --    , trunc(s.snap_time, 'DD')     DAY
    --    , to_number(to_char(s.snap_time, 'HH24'))  HOUR
    --   -- , to_char(s.snap_time, 'MI')    MINUTE
    --    , 0           MINUTE
        , trunc(
          lag(s.snap_time, 1)
          over(
           partition by
          v.dbid
           , i.instance_name
           , v.instance_number
           , v.event
         order by
          s.snap_time
          , 'HH24'
         )           SNAP_TIME
        , v.event_type        EVENT_TYPE
        , v.event          EVENT_NAME
        , nvl(
        decode(
         greatest(
          time_waited_micro,
          nvl(
           lag(time_waited_micro,1,0)
           over(
            partition by
             v.dbid
              , i.instance_name
              , v.instance_number
              , v.event
            order by v.snap_id
           , time_waited_micro
         time_waited_micro,
         time_waited_micro - lag(time_waited_micro,1,0)
         over (
          partition by
           v.dbid
            , i.instance_name
            , v.instance_number
            , v.event
          order by v.snap_id
         time_waited_micro
           , time_waited_micro
         ) / 1000000         SECONDS_SPENT
        , total_waits         WAIT_COUNT
      from
       (select distinct dbid, instance_name, instance_number from stats$database_instance) i
        , stats$snapshot s
        , ( select
         snap_id, dbid, instance_number, 'WAIT' event_type, event, time_waited_micro, total_waits
        from
         stats$system_event
        where
         event not in (select event from stats$idle_event)
        union all
        select
         snap_id, dbid, instance_number,
         case
          when name in ('CPU used by this session', 'parse time cpu', 'recursive cpu usage') then 'CPU'
          when name like 'OS % time' then 'OS'
          else 'STAT'
         end,
         name , value, 1
        from
         stats$sysstat
    --    where      name in ('CPU used by this session', 'parse time cpu', 'recursive cpu usage')
    --    or  name like('OS % time')
    --    or 1 = 2 -- this will be a bind variable controlling whether all stats need to be returned
       ) v
      where
       i.dbid = s.dbid
      and i.dbid = v.dbid
      and s.dbid = v.dbid
      and s.snap_id = v.snap_id
      and s.snap_time between '%FROM_DATE%' and '%TO_DATE%'
      and i.instance_name = '%INSTANCE%'
    select * from (
      select
       instance_name
        , instance_number
        , snap_time
        , trunc(snap_time, 'DD')  DAY
        , to_char(snap_time, 'HH24') HOUR
        , to_char(snap_time, 'MI') MINUTE      
        , event_type  
        , event_name  
        , seconds_spent
        , wait_count  
        , ratio_to_report(seconds_spent) over (
    --      partition by (to_char(day, 'YYYYMMDD')||to_char(hour,'09')||to_char(minute, '09'))
          partition by (snap_time)
          ) ratio
      from fsq
      where
       snap_time is not null -- lag(s.snap_time, 1) function above will leave time NULL for first snapshot
      -- to_char(day, 'YYYYMMDD')||to_char(hour,'09')||to_char(minute, '09')
      -- > ( select min(to_char(day, 'YYYYMMDD')||to_char(hour,'09')||to_char(minute, '09')) from fsq)
    where ratio > 0
    order by
        instance_name
      , instance_number
      , day
      , hour
      , minute
      , event_type
      , seconds_spent desc
      , wait_count desc
    Error at line 6
    ORA-00604: error occurred at recursive SQL level 1
    ORA-00972: identifier is too long

    Hi Alex,
    Subquery factoring a.k.a. the with-clause should be possible on 9.2:
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_103a.htm#2075888
    (used it myself as well on 9.2)
    @OP
    I recall having problems myself using PL/SQL Developer and trying to get the with clause to work on 9.2 some years ago.
    A workaround might be to create a view based on the query.
    Also, your error message is "ORA-00972: identifier is too long"...
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14219/e900.htm#sthref419
    Can't test things currently, no 9.2 available at the moment, but perhaps tomorrow I'll have a chance.

  • Whats wrong in this SQL - Help Required..

    Hi,
    Can you please tell me what is wrong in this SQL Query.
    select
    case
    when
    (SELECT territory_code
    FROM
              fnd_territories
              where territory_code like 'BR') then
    (SELECT description
                        FROM fnd_descr_flex_contexts_tl
    WHERE descriptive_flexfield_name='JG_PO_VENDOR_SITES'
                        AND descriptive_flex_context_code='JL.BR.APXVDMVD.SITES')
    else
    NULL
    end result
    FROM dual;
    Thanks,

    Based on the info supplied, here's a few possibilities,
    you've typed the table name incorrectly
    You've not restricted the results correctly,
    you're using a version of oracle that doesn't support the CASE expression
    You're using SQL server, which doesn't have the dual table.
    you've / someone has manipulated teh dual table so that it now has 4billion and one rows
    The subquery in your case statement returns more than one row.
    1. It's poorly/not formatted.
    2. It's not in code tags
    3. You haven't given us anywhere near enough info e.g. Error messages, what you're actually trying to do etc, etc

  • What is this error java.sql.SQLException: Bad format for number ?

    Dear All,
    I am reading few values from database. Then I get this error "MyError:Error : java.sql.SQLException: Bad format for number 'Sarawak' in column 6. " So what is this error referring to. I have checked the database column and its value fits according the data type. Any hints please?

    I have checked the database column and its value fits according the data type.Check again. Then check again. Keep checking until you find your error. You are trying to read a string containing "Sarawak" as a number. You have "getInt(6)" or other numeric type, and the 6th column in the select statement is not numeric.

  • "SQlite Version Error The application has been updated, but your version of SQlite is too old and the application cannot run." What is this all about?? Shall I give up on Firefox?

    When I tried to use Firefox this morning I got this message with exclamation marks.
    "SQlite Version Error The application has been updated, but your version of SQlite is too old and the application cannot run."
    What is this all about?? Shall I give up on Firefox?

    Sorry to hear that. I understand your frustration and I hope they send back a better working N78-3.
    Myself, I count myself lucky. Everything works perfectly for me right now...email, bluetooth, maps, gps, 3rd party apps, battery life, 3G, wifi, etc. etc.
    The only issue I've been having is the dreaded reboots but I believe that may have to do with 3rd party apps. I recently uninstalled Google Search app from my N78 and since then it hasn't rebooted or shown any issues. This seems odd at first but makes sense if you think about the fact that the Google Search app loads itself into memory and runs in the background at all times.
    I did this this past Tuesday night and so far no reboots, crashes or any problems. I'm sure I just jinxed myself but I've been using it heavily over the last few days with no issues. Prior to this, it would usually reboot every 2 days. If it doesn't reboot for another few days I'll be happy.
    I would normally not stand for this but I just love the phone and if I got something else it'd probably be the iPhone 3G which has perhaps more software bugs and issues than the N78-3!!
    Best of luck. Here's hoping they release an update soon.

  • Sql.log what is this all about

    hi
    i wanted to know why is this sql.log created on any drive on each jar opperation
    contents being
    vin(T)_ fff8382f:ffc73d0f     ENTER SQLAllocEnv
              HENV * 0x0b41f724
    vin(T)_ fff8382f:ffc73d0f     EXIT SQLAllocEnv with return code 0 (SQL_SUCCESS)
              HENV * 0x0b41f724 ( 0x0b70ff24)
    vin(T)_ fff8382f:ffc73d0f     ENTER SQLAllocConnect
              HENV 0x0b70ff24
              HDBC * 0x0b41f688
    vin(T)_ fff8382f:ffc73d0f     EXIT SQLAllocConnect with return code 0 (SQL_SUCCESS)
              HENV 0x0b70ff24
              HDBC * 0x0b41f688 ( 0x0b610194)

    i didnt get the debuggind stuff a little confused on
    who initiates
    that , as i have not.Let me try a slightly different take on what I said before.
    Use "Start" and go to "Settings", then "Control Panel"
    In there find either something that refers to "ODBC" or "Data Sources". You might have to poke around however this will be there. (Let me repeat it is there - it might be in a sub folder in the control panel but it is always there.)
    Open it.
    Look for a tab that says "Tracing", click on that.
    I can't say for sure what you will find there, but on my system there is a big button that says "Start Tracing Now" and then says "Stop Tracing Now" when I click on it. Obviously when it says "Stop Tracing Now" it is no longer tracing. Yours will have something similar. Yours is turned on.
    You will also notice that the file that it uses for tracing is called "sql.log". But once you turn the tracing off that no longer matters.

  • What is native Sql data types and does oracle support this?

    what is native Sql data types
    Does oracle support this?

    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#g31099

  • HT204406 I downloaded a song that is not playing.  When i click to report a problem it gives me an error that says "To many HTTP redirects".  What does this mean and how do I fix it?  Thank you!

    I downloaded a song that is not playing.  When i click to report a problem it gives me an error that says "To many HTTP redirects".  What does this mean and how do I fix it?  Thank you!

    The following support articles should help:
    * https://support.mozilla.com/kb/Could+not+initialize+the+browser+security+component
    * https://support.mozilla.com/kb/AUS+Update+XML+File+Malformed+200

Maybe you are looking for

  • Large(r) Tools

    Part of getting our house ready to sell is power washing all the concrete down the driveway and in front of the garage (my wife LOVES to have a hose in her hand, any kind of hose) After tiring of "home size" electric power washers that don't last mor

  • Xml clause for group by statement t-sql.

    Hello , I have this data. create table #students id int identity(1,1) primary key, student_id int not null, [year] int not null, [subject] varchar(50) not null, [marks] int not null insert into #students student_id , [year] , [subject] , [marks] valu

  • Blank sms ?

    So, ive send text message to whatever carrier and they arrive with no content, or sometimes with alfanumeric characters, att has review everything, apple says maybe language programing in device etc, anyone has solved this issue? for me happens in US

  • Change insets of a JLabel

    i need a lot of space in the left and right of a JLabel. how can i change the insets??? THANKS!!!

  • Administrato CF 10 error invoking cfc after update.

    went through our update cycle for our CF 10 admin for the latest updates.  We are now receiving the following error: "Error invoking CFC /CFIDE/Administrator/updates/download.cfc: internal server error [enable debugging by adding 'cfdebug' to your UR