Run the query according to the transaction.

Hi all

I am able to run the query, but I want to run query award date.
I created the timer for shape and I want when user update the record for the same registration date must run, do not run the query from the previous day.
is this possible?
can someone help me?


Sarah

See other thread

Tags: Oracle Development

Similar Questions

  • Validation of the transaction in OT, jdev Version 11.1.1.5.0 levels

    Hello
    I use Jdev version 11.1.1.5.0.
    I have a requirement of data validation in af:table the validation/registration.
    For this I use validator method in OT.

    Level of validation is,
    See running the transaction level.

    Ideally, this method should perform only at the time of the transaction.
    However, the method runs every time what current row has changed in the dashboard UI.

    Please help me...

    Thank you
    Nag

    You can try to override the beofrCommit method in the EntityImpl class
    something like this:

        @Override
        public void beforeCommit(TransactionEvent transactionEvent) throws oracle.jbo.JboException {
            if (put your condition)
                throw new JboException ("your error message");
            else
                super.beforeCommit(transactionEvent);
        }
    
  • 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 »

  • Select the query takes a long time to run the second time

    Hi all

    I have Oracle 11 GR 1 material in windows server 2008 R2.
    I have a few tables with 10 million documents. When I run the select query to the tables of first time, it gives me a result in 15 seconds, but if I run the script even twice in the same session, I get the result in 15 minutes to complete...

    Why it's happening? What can be the solution for this?

    Thank you and best regards,
    Vikash jain (DBA Junior)

    What I know is that this feedback from cardinality generates more problems than improving the performance is, in fact, its main objective. But first look at which is was written in the link I posted above

    "Return of cardinality was introduced in the Oracle 11 g database 2. The purpose of this function is to automatically improve plans for queries that are executed repeatedly, _For that the optimizer does not estimate the cardinalities in the properly_ plan"

    If the cardinality feedback kiks in your case it is certainly because you do not have an exact statistics. Get the command the explain plans that I have shown you with the E-lines and A-lines (lines estimates and actual lines) and see where things are poorly estimated.

    If you want to disable the cardinality feedback then add the indicator according to your request

    /*+ opt_param('_optimizer_use_feedback','false') */
    

    Best regards

    Mohamed Houri
    www.hourim.WordPress.com

    Published by: Mohamed Houri on November 22, 2012 02:11
    Published by: I was looking for the exact indication of how do I deactivate the cardinality feedback and I foud in an ot the Dominic post in otn :-)

    Published by: Mohamed Houri on November 22, 2012 02:15

  • Change the color of the font after running a query

    Hi all

    I need to change the color of the font after running a query. I mean, according to the value of a column to say BRANCH_STATUS , the color of the font of this column will has changed.

    I applied the following on the times-news-block-instance trigger code, but I get all BRANCH_STATUS lines become same color:
    execute_query;
    IF: BRANCH_STATUS = "ONLINE" THEN
    SET_ITEM_PROPERTY ('BRANCH_STATUS', 'r191g223b191', FOREGROUND_COLOR);
    ELSIF: BRANCH_STATUS = "OFFLINE" THEN
    SET_ITEM_PROPERTY ('BRANCH_STATUS', 'R255g0b0', FOREGROUND_COLOR);
    ANOTHER NULL.
    END IF;
    I want to show a different color for different values of ' BRANCH_STATUS *.»

    Sorry, I'm wrong: in point-instance-property, there is no foreground property - set a Visual attribute and use it with

    SET_ITEM_INSTANCE_PROPERTY(..., VISUAL_ATTRIBUTE, 'your_attribute');
    
  • Publish everything in running the publishing application ATG - CRS Server. Unable to query the table 'das_id_generator '.

    Hello

    I use ATG version 10.2 and you have configured CRS application by IMC. All data import and deployments have been successful.

    Applications of short (MDEX 6.4.1, CASE 3.2.1 6.4.1.2, tools and Framework 3.1.2 platform services) are running: port 8006, 8500, race 8888.

    Now MY PROBLEM IS in TWO PARTS:

    PART 1)  Ran the store on jboss, has worked well, core application started without any error.  When trying to load the homepage, get following error message:

    16:42:25, 926 full repository INFO [SEORepository] SQL boot

    16:43:32, 653 ERROR [DynamoServlet]

    CAUGHT AT:

    Container: ATG.servlet.jsp.ContainerJspException: Cannot find the named component: / atg/registry/Slots/HomeTheme; Source: javax.servlet.ServletException: Cannot find the named component: / atg/registry/Slots/HomeTheme

    at atg.taglib.dspjsp.ParamTag.doStartTag(ParamTag.java:419)

    at org.apache.jsp.navigation.gadgets.homePagePromotions_jsp._jspx_meth_dsp_005fparam_005f0(homePagePromotions_jsp.java:1021)

    at org.apache.jsp.navigation.gadgets.homePagePromotions_jsp._jspService(homePagePromotions_jsp.java:219)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)

    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:543)

    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:480)

    at atg.servlet.WrappingRequestDispatcher.include(WrappingRequestDispatcher.java:123)

    at atg.taglib.dspjsp.IncludeTag.doEndTag(IncludeTag.java:883)

    at org.apache.jsp.index_jsp._jspx_meth_dsp_005finclude_005f1(index_jsp.java:633)

    to org.apache.jsp.index_jsp.access$ 1 (index_jsp.java:622)

    to org.apache.jsp.index_jsp$ Helper.invoke1 (index_jsp.java:685)

    to org.apache.jsp.index_jsp$ Helper.invoke (index_jsp.java:711)

    at org.apache.jsp.tag.web.store.pageContainer_tag._jspx_meth_c_005fwhen_005f1(pageContainer_tag.java:2757)

    at org.apache.jsp.tag.web.store.pageContainer_tag.doTag(pageContainer_tag.java:812)

    at org.apache.jsp.index_jsp._jspx_meth_crs_005fpageContainer_005f0(index_jsp.java:598)

    at org.apache.jsp.index_jsp._jspx_meth_dsp_005fpage_005f1(index_jsp.java:565)

    at org.apache.jsp.index_jsp._jspService(index_jsp.java:127)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

    ...........................

    ...........................

    ...........................

    ...........................

    At this point, the CRS page opens but no short content. Don't load no registration, no image on the home page does display, NO SEARCH BOX displayed in the header.

    PART 2)  On top of that when I try to run the server pubishing on JBOSS, start does'nt server and responds to error. If the das_id_generator table exists in DB for all 4 patterns.

    16:09:41, 082 INFO [ScreenLog] with logging of external for debug messages and trace kernel to avoid hidden kernel logging information. Set the property /atg/dynamo/service/logging/ScreenLog.useInfoForDebug to false nucleus to use external instead trace and debug logging.

    16:09:41, 199 INFO [Version] HV000001: Hibernate Validator 4.3.1.Final

    16:09:41, 748 Truncating WARN [ClusterBroadcaster] serviceProperties "commandLineModules" key value

    16:09:42, size INFO [STDOUT] 345 (ERR_QUERY_TABLE, das_id_generator

    16:09:42, 351 ERROR [IdGenerator]

    CAUGHT AT:

    Container: ATG.service.IdGen.IdGeneratorException; Source: Container: ATG.service.IdGen.IdGeneratorException: Cannot query the table 'das_id_generator '. Please make sure that the table exists and is accessible before you start this service. ; Source: Java.Sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

    at atg.service.idgen.PersistentIdGenerator.initialize(PersistentIdGenerator.java:389)

    at atg.service.idgen.AbstractSequentialIdGenerator.doStartService(AbstractSequentialIdGenerator.java:643)

    at atg.nucleus.GenericService.startService(GenericService.java:561)

    at atg.nucleus.NucleusNameResolver.startService(NucleusNameResolver.java:1726)

    at atg.nucleus.NucleusNameResolver.configureAndStartService(NucleusNameResolver.java:1397)

    at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:928)

    at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:667)

    at atg.nucleus.NucleusNameResolver.createFromName(NucleusNameResolver.java:648)

    at atg.nucleus.NucleusNameResolver.resolveName(NucleusNameResolver.java:493)

    at atg.nucleus.ConfigurationRef.getValue(ConfigurationRef.java:119)

    at atg.nucleus.SimpleComponentState.setBeanProperty(SimpleComponentState.java:403)

    at atg.nucleus.SimpleConfigurationState.saveToBean(SimpleConfigurationState.java:240)

    at atg.nucleus.SimpleConfigurationState.configureBean(SimpleConfigurationState.java:263)

    at atg.nucleus.BeanConfigurator.configureBean(BeanConfigurator.java:297)

    at atg.nucleus.PropertyConfiguration.configureService(PropertyConfiguration.java:984)

    at atg.nucleus.SingleNucleusConfigurator.configureService(SingleNucleusConfigurator.java:84)

    at atg.nucleus.NucleusNameResolver.configureService(NucleusNameResolver.java:1643)

    at atg.nucleus.NucleusNameResolver.configureAndStartService(NucleusNameResolver.java:1368)

    ........................

    ........................

    ........................

    An early response would be really useful because we have demo in 10 days.

    Kind regards

    Ben Milot

    Thank you for this comment.

    I had created a fresh scheme for publication but the jboss was still pointing to the old.

    I've updated this pointers in file @ /server/ atg atg - ds - ds.xml. Worked like a charm!

    If 2nd EDITION solved.


    The QUESTION 1 depended on question 2. Once I ran publishing and completed the full deployment on ICC, 1st edition got resolved.

    Thanks to shaik and Grando

    Kind regards

    Ben Milot

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

  • NoAvailableServersException when you run the query in applications

    I only run the UI applications connected to a carrier co-located in my distributed system. When I run a query of the applications I have a NoAvailableServersException. The trace of the full stack of the applications log is below. I can run the same query successfully in gfsh on the same machine, the I'm running the applications. I' wvv looked through the applications documentation but can't find problems with my setup. Please let me know if you need more information.

    Tom

    [06/02/2013 INFO 17:39:19.135 IS main] Manual applications path is C:\vmware\vfabric-gemfire\vFabric_GemFire_70_b38623\tools\DataBrowser\docs\index.html
    [06/02/2013 INFO 17:39:19.512 IS main] Start interviewing for the results link to JMX Manager operation.
    [17:39:19.692 JMXCallExecutorThread IS SERIOUS 2013/02/06] An exception occurred while connecting to the mark on the host: idcprdgflocator2.carecorenational.com and port: 1099: com.gemstone.gemfire.management.ManagementException: Locator has failed. It is normal if the index was arrested. If it wasn't not check his diary for exceptions.
    [06/02/2013 INFO 17:39:19.692 IS JMXCallExecutorThread] Try to connect to a JMX Manager on the host: idcprdgflocator2.carecorenational.com and port: 1099
    [06/02/2013 INFO 17:39:19.793 IS JMXCallExecutorThread] Connected to the Gemfire distributed system
    [06/02/2013 INFO 17:39:21.666 IS JMXCallExecutorThread] Added members: ccnscupadsgf01 (10552) < v14 >: 4709
    [06/02/2013 INFO 17:39:21.679 IS JMXCallExecutorThread] Updated the refreshInterval to 60000
    [06/02/2013 INFO 17:39:23.594 IS JMXCallExecutorThread] GemFire (7.0) Cache is created. Support PDX is available.
    [06/02/2013 INFO 17:39:23.710 IS JMXCallExecutorThread] GemFire jar in the classpath version: 7.0
    [06/02/2013 INFO 17:39:23.710 IS JMXCallExecutorThread] Is the system of GemFire version: 7.0
    [06/02/2013 INFO 17:39:23.710 IS JMXCallExecutorThread] The LIMIT clause is supported by this version of the GemFire system: false
    [06/02/2013 INFO 17:39:23.711 IS JMXCallExecutorThread] The user is connected successfully to JMX Manager to idcprdgflocator2.carecorenational.com: 1099
    [06/02/2013 INFO 17:40:01.633 IS query run] Pool preparation for members:
    [06/02/2013 SERIOUS, 17:40:04.692 IS run query] Error occurred during execution of the query: com.gemstone.gemfire.mgmt.DataBrowser.controller.QueryConfigurationPrms@5608a6fc com.gemstone.gemfire.mgmt.DataBrowser.query.QueryExecutionException: com.gemstone.gemfire.cache.client.NoAvailableServersException
    at com.gemstone.gemfire.mgmt.DataBrowser.query.QueryUtil.executeQuery(QueryUtil.java:74)
    at com.gemstone.gemfire.mgmt.DataBrowser.connection.internal.GemFireClientConnectionImpl.executeQuery(GemFireClientConnectionImpl.java:122)
    to com.gemstone.gemfire.mgmt.DataBrowser.controller.internal.QueryExecutionHelper$ QueryExecutor.run (QueryExecutionHelper.java:169)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: com.gemstone.gemfire.cache.client.NoAvailableServersException
    at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.borrowConnection(ConnectionManagerImpl.java:246)
    at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:135)
    at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:114)
    at com.gemstone.gemfire.cache.client.internal.PoolImpl.execute(PoolImpl.java:638)
    at com.gemstone.gemfire.cache.client.internal.QueryOp.execute(QueryOp.java:51)
    at com.gemstone.gemfire.cache.client.internal.ServerProxy.query(ServerProxy.java:81)
    at com.gemstone.gemfire.cache.query.internal.DefaultQuery.executeOnServer(DefaultQuery.java:282)
    at com.gemstone.gemfire.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:213)
    at com.gemstone.gemfire.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:195)
    at com.gemstone.gemfire.mgmt.DataBrowser.query.QueryUtil.executeQuery(QueryUtil.java:70)
    ..
    . 3 more
    [06/02/2013 SERIOUS, 17:40:04.694 IS query result processor] Error executing query: com.gemstone.gemfire.mgmt.DataBrowser.query.QueryExecutionException: com.gemstone.gemfire.cache.client.NoAvailableServersException
    at com.gemstone.gemfire.mgmt.DataBrowser.query.QueryUtil.executeQuery(QueryUtil.java:74)
    at com.gemstone.gemfire.mgmt.DataBrowser.connection.internal.GemFireClientConnectionImpl.executeQuery(GemFireClientConnectionImpl.java:122)
    to com.gemstone.gemfire.mgmt.DataBrowser.controller.internal.QueryExecutionHelper$ QueryExecutor.run (QueryExecutionHelper.java:169)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: com.gemstone.gemfire.cache.client.NoAvailableServersException
    at com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManagerImpl.borrowConnection(ConnectionManagerImpl.java:246)
    at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:135)
    at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:114)
    at com.gemstone.gemfire.cache.client.internal.PoolImpl.execute(PoolImpl.java:638)
    at com.gemstone.gemfire.cache.client.internal.QueryOp.execute(QueryOp.java:51)
    at com.gemstone.gemfire.cache.client.internal.ServerProxy.query(ServerProxy.java:81)
    at com.gemstone.gemfire.cache.query.internal.DefaultQuery.executeOnServer(DefaultQuery.java:282)
    at com.gemstone.gemfire.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:213)
    at com.gemstone.gemfire.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:195)
    at com.gemstone.gemfire.mgmt.DataBrowser.query.QueryUtil.executeQuery(QueryUtil.java:70)
    ... 3 more

    If you set the gemfire bind-address on the cache server, applications will be able to connect. If a bind-address is not defined in gemfire.properties for a server remote cache, applications unfortunately just silently by default is localhost. This is something that will have to solve. In the meantime, you can work around this by setting the property gemfire bind-address on the cache servers for either the IP address or host name.

  • I have run this query to get the result as below, but, even if my query is running fine, that I do not get the expected result.

    I'm looking for only column compare to my same target table as a table source.

    My query:


    Select case when column_name_s is null and column_name_t is not null

    then "alter table GRADE_CONVERSION drop | column_name_t | ';'

    When column_name_s is not null and column_name_t is null

    then "alter table GRADE_CONVERSION add | column_name_s | ' ' || data_type_s | « ; »

    else 'alter table modify GRADE_CONVERSION | column_name_t | ' ' || data_type_t | « ; »

    alterations of the end

    from (select s.column_name column_name_s, t.column_name column_name_t,

    s.data_type data_type_s, t.data_type data_type_t

    (select column_name, column_id, data_type

    of all_tab_cols@database

    where owner = 'erhan.

    and table_name = "GRADE_CONVERSION."

    + 1

    full outer join

    (select column_name, column_id, data_type

    of all_tab_cols@database

    where owner = 'sarigul.

    and table_name = "GRADE_CONVERSION."

    + 6

    on s.column_name = t.column_name

    )




    Tables:



    Target table: table GRADE_CONVERSION in sarigul@database


    LETTER_GRADEVARCHAR2 (2)
    GRADE_POINTNUMBER (3.2)
    MAX_GRADENUMBER (3)
    MIN_GRADENUMBER (3)




    Table source: Table GRADE_CONVERSION in erhan@database

    LETTER_GRADEVARCHAR2 (2)
    GRADE_POINTNUMBER (3.2)
    MAX_GRADENUMBER (3)
    MIN_GRADENUMBER (3)
    CREATED_BYVARCHAR2 (30)
    CREATED_DATEDATE
    MODIFIED_BYVARCHAR2 (30)
    MODIFIED_DATEDATE



    want to see output that is similar to this * (please ignore the names of column here it's just a clear example :))


    ALTER table Target_table change BOOK_ID Varchar2 (4);

    ALTER table Target_table I addSBN_10 Varchar2(13), null;

    ALTER table drop TITLE Target_table;

    Erhan_toronto wrote:

    1.I used src.nullable src_nullable and tgt.nullable tgt_nullable but only show Yes as below: but want to see the result as not null or null

    ALTER table TEST_TARGET change the NUMBER of MAX_GRADE (3, 2) Yes

    Ok. So it's all about the Yes and the no decoding to Default Null or Not Null, isn't it?

    So, to test, change one of the table of sample for NOT NULL columns in the source table, and then run the following query:

    with src as
    (
      select src.table_name src_table_name, src.column_name src_col_name, src.data_type src_data_type, src.data_length src_data_len, src.data_precision src_data_precision, src.data_scale src_data_scale,
             src.nullable src_nullable
        from user_tab_columns src
       where table_name = 'TEST_SOURCE'
    ),
    tgt as
    (
      select tgt.table_name tgt_table_name, tgt.column_name tgt_col_name, tgt.data_type tgt_data_type, tgt.data_length tgt_data_len, tgt.data_precision tgt_data_precision, tgt.data_scale tgt_data_scale,
             tgt.nullable tgt_nullable
        from user_tab_columns tgt
       where table_name = 'TEST_TARGET'
    ),
    col_details as
    (
      select src.src_table_name, nvl(tgt.tgt_table_name, first_value(tgt_table_name) over(order by tgt_table_name nulls last)) tgt_table_name,
             src.src_col_name, src.src_data_type, src.src_data_len, src.src_data_precision, src.src_data_scale, src.src_nullable,
             tgt.tgt_col_name, tgt.tgt_data_type, tgt.tgt_data_len, tgt.tgt_data_precision, tgt.tgt_data_scale, tgt.tgt_nullable
        from src
        left outer join tgt
          on (
              src.src_col_name = tgt.tgt_col_name
             )
    )
    select *
      from (
            select case
                    when tgt_data_type != src_data_type or tgt_data_len != src_data_len or tgt_data_precision != src_data_precision or tgt_data_scale != src_data_scale or src_nullable != tgt_nullable
                      then 'alter table ' || tgt_table_name || ' modify ' || tgt_col_name || ' ' || src_data_type || ' (' ||
                      case when src_data_type in ('DATE') then null
                           else
                                case
                                  when src_data_type in ('VARCHAR', 'VARCHAR2')
                                    then nvl(to_char(src_data_len), ' ') || ') '
                                  else  decode(nvl(src_data_precision, -1), -1, null, nvl(to_char(src_data_precision), ' ') || ', ' || nvl(to_char(src_data_scale), ' ') || ')')
                                end
                      end
                      || decode(src_nullable, 'NO', ' NOT NULL', ' DEFAULT NULL')
                    when tgt_col_name is null
                      then 'alter table ' || tgt_table_name || ' add ' || src_col_name || ' ' || src_data_type ||
                      case when src_data_type in ('DATE') then null
                           else
                                case
                                  when src_data_type in ('VARCHAR', 'VARCHAR2')
                                    then nvl(to_char(src_data_len), ' ') || ') '
                                  else  decode(nvl(src_data_precision, -1), -1, null, nvl(to_char(src_data_precision), ' ') || ', ' || nvl(to_char(src_data_scale), ' ') || ')')
                                end
                      end
                      || decode(src_nullable, 'NO', ' NOT NULL', ' DEFAULT NULL')
                   end alter_statement
              from col_details
            )
    where alter_statement is not null;
    

    Erhan_toronto wrote:

    2. when I run below under user sarigul and erhan I get the result as OWNER, TABLE_NAME, COLUMN_NAME DATA_TYPE... I have a link between two users. They have access to two tables.

    • Select * from all_tab_columns

    where owner = 'erhan' and table_name = "TEST_SOURCE."

    • Select * from all_tab_columns

    where owner = 'sarigul' and table_name = "TEST_TARGET."

    Alright. This means that you both users are on the same database. Only change, you will have to do in the above query is so change user_tab_columns to all_tab_columns and add the OWNER predicate respectively with the clause.

  • Data not to see the detail block on running the query

    I have a dev - 6i form. It contains two revenge joined database. The form was working properly but now all of a sudden, as I F8 run query it gives two error messages and do not run the block of detail data.

    FRM-40819: System Variable is not editable.
    FRM-40735: trigger YOU POPULATE DETAILS raised unhandled exception ORA-06502.
    What is the reason how to get rid of him?

    Hello

    Unless changes occurred, you will not get error, maybe it occurred without your knowledge.

    Cases - open your source fmb file, rename and delete the link and create the link - compiles now.

    Run the form, and then paste the result here.

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

    Gul says:
    I have a dev - 6i form. It contains two revenge joined database. The form was working properly but now all of a sudden, as I F8 run query it gives two error messages and do not run the block of detail data.

    FRM-40819: System Variable is not editable.
    FRM-40735: trigger YOU POPULATE DETAILS raised unhandled exception ORA-06502.
    What is the reason how to get rid of him?

  • use F8 &amp; F10 keys on the keyboard to run the query and save a form

    I created a screen. Here I can save by pressing CTRL + S (written a validation key trigger) or the button Save, I placed.
    Now the user want to F10 to save & key F8 to run the query.
    How can I do? Should what trigger I write the code...
    I use oracle 10g and oracle developer suite 10 g.
    I have fmrweb.res as follows:-


    9: 0: 'Tab': 1: "then on the ground."
    9: 2: "Ctrl + Tab": 1: "then on the ground."
    9: 1: "Shift + Tab": 2: "previous field.
    9: 3: 'Shift + Ctrl + Tab': 2: "previous field.
    85: 2: "Ctrl + U": 3: "clear the field".
    38: 0: 'Up': 6: 'Up '.
    40: 0: 'Down': 7: "Down".
    33: 0: 'PG': 12: "scroll to top".
    34: 0: "PageDown": 13: "scroll."
    69: 2: 'Ctrl + E': 22: 'Edit '.
    10: 0: "Enter": 27: «Back»
    120: 0: 'F9': 29: "list of values".
    76: 2: "Ctrl + L": 29: "list of values".
    81: 2: 'Ctrl + Q': 32: "Exit".
    75: 2: "Ctrl + K": 35: 'display keys '.
    112: 2: 'Ctrl + F1': 35: 'display keys '.
    83: 2: 'Ctrl + S': 36: 'engage '.
    121: 2: "F10": 36: 'engage '.
    114: 1: 'SHIFT + F3': 61: 'next primary key '.
    115: 1: "SHIFT + F4": 62: "delete folder".
    117: 1: "SHIFT + F6": 63: 'delete folder '.
    115: 0: "F4": 64: "Double registration".
    117: 0: 'F6': 65: "insert record".
    119: 1: "SHIFT + F8": 66: "a next Recordset.
    1005: 0: 'Down': 67: "then save.
    1004: 0: 'Up': 68: "history".
    40: 1: 'Shift + down': 67: "then save.
    38: 1: "shift + up": 68: "history".
    116: 1: "Shift + F5": 69: 'clear the block '.
    116: 0: 'F5': 70: "block the Menu."
    34: 1: "shift + page down": 71: 'then block '.
    33: 1: ' shift + Pg. Prev ': 72: "previous block.
    34: 2: "Ctrl + PG. Next": 71: 'then block '.
    33: 2: "Ctrl + PG. Prev': 72: "previous block.
    114: 0: "F3": 73: "duplicate field '.
    118: 1: "Shift + F7": 74: 'clear form '.
    118: 0: "F7": 76: "enter the query."
    119: 0: 'F8': 77: 'execute the query. "
    122: 0: 'F11': 76: "enter the query."
    122: 2: "Ctrl + F11": 77: 'execute the query. "
    112: 1: "SHIFT + F1": 78: "error to display.
    80: 2: 'Ctrl + P': 79: 'print '.
    113: 1: "SHIFT + F2": 80: "request Count".
    123: 0: "F12": 81: "update file".
    121: 3: 'Shift + Ctrl + F10': 82: "function 0".
    112: 3: 'Shift + Ctrl + F1': 83: «Function 1"»
    113: 3: 'Shift + Ctrl + F2': 84: «Function 2"»
    114: 3: 'Ctrl + Shift + F3': 85: «function 3"»
    115: 3: 'Shift + Ctrl + F4': 86: «function 4"»
    116: 3: 'Shift + Ctrl + F5': 87: «Function 5"»
    117: 3: 'Shift + Ctrl + F6': 88: «function 6"»
    118: 3: 'Shift + Ctrl + F7': 89: «Function 7"»
    119: 3: 'Shift + Ctrl + F8': 90: «Function 8"»
    120: 3: 'Shift + Ctrl + F9': 91: «Function 9"»
    113: 0: 'F2': 95: "list of tab Pages.
    72: 2: "Ctrl + H": 30: "Help".
    112: 0: 'F1': 30: "Help".

    Please suggest...

    Hello.

    First of all check that you have set "term" among others in the variable 'otherparams' in formsweb.cfg

    For example:

    otherparams = expression = term %

    Then make sure that you put the correct path for the keyboard mapping file in the variable "term" as I wrote in the previous post.

    Things should work as I did several times.

    Best regards.

  • Is there a way of only not to run a query on the rendering of the table?

    Is there a way of only not to run a query associated with an af:table on the rendering of the table on the page?
    I want to this control programmatically.

    Examples will be very appreciated.

    Yes, there is.

    {: identifier of the thread = 2362354}

  • Query by running the Diffrence of STATS$ EVENT_HISTOGRAM

    I am tiring to perform an analysis on STATS$ EVENT_HISTOGRAM (created in PERFSTAT).

    I would like to end up with a result like this;
    SNAP_ID   SNAP_TIME                 DB_RESTART    WAIT_COUNT_LE_7MS   WAIT_COUNT_GT_7MS  TOTAL_WAIT_COUNT   WAIT_COUNT_PERCENT_LE_7MS  WAIT_COUNT_PERCENT_GT_7MS
    397          2/9/2012 2:02:39 PM    NO             3,311              16,261             19,572             16.92                      83.08
    398          2/9/2012 2:35:03 PM    NO             10,040             11,499             21,539             46.61                      53.39
    399          2/9/2012 5:02:22 PM    YES            11,137             113,916            225,053            49.38                      50.62
    400          2/9/2012 5:32:21 PM    NO             5,880              5,047              10,927             53.81                      46.19
    401          2/9/2012 6:02:21 PM    NO             1,342              3,004              4,346              30.88                      69.12
    The rules are (I know so far):
    1. all values correspond to the difference of the previous SNAP_ID
    2. the first SNAP_ID has no precedential value, so it will not appear in the result set. In our case, it was SNAP_ID 396.
    3. when the STATS$ SNAPSHOT. STARTUP_TIME the row changes previous this indicates a DB_RESTART = YES.
    4. when DB_RESTART = YES do not subtract the values of previous SNAP_ID.

    I'm on Oracle 11.1.0.7

    Create the table EVENT_HISTOGRAM STATS$:
    CREATE TABLE STATS$EVENT_HISTOGRAM
    (
      SNAP_ID          NUMBER,
      DBID             NUMBER,
      INSTANCE_NUMBER  NUMBER,
      EVENT_ID         NUMBER,
      WAIT_TIME_MILLI  NUMBER,
      WAIT_COUNT       NUMBER
    );
    Load my data in the table EVENT_HISTOGRAM STATS$:
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI,WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 1,47088592);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 2, 7397910);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 4, 1049509);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 8, 2384662);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 16, 12446589);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 32, 6698196);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 64, 934431);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 128, 655758);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 256, 213053);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 512, 73814);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 1024, 6088);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 2048, 1825);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 4096, 2169);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 8192, 3122);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 16384, 4144);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 32768, 330);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 65536, 662);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 131072, 9);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 262144, 28);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (396, 2359907137, 1, 2652584166, 524288, 22);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 1, 47091161);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 2, 7398497);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 4, 1049664);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 8, 2386574);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 16, 12454531);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 32, 6701651);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 64, 934831);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 128, 656657);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 256, 213223);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 512, 74218);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 1024, 6167);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 2048, 1869);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 4096, 2237);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 8192, 3317);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 16384, 4779);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 32768, 358);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 65536, 663);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 131072, 12);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 262144, 47);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (397, 2359907137, 1, 2652584166, 524288, 29);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 1, 47100463);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 2, 7399116);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 4, 1049783);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 8, 2387726);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 16, 12459548);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 32, 6704135);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 64, 935351);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 128, 657496);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 256, 213525);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 512, 74515);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 1024, 6224);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 2048, 1898);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 4096, 2323);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 8192, 3503);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 16384, 5229);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 32768, 381);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 65536, 671);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 131072, 20);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 262144, 68);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (398, 2359907137, 1, 2652584166, 524288, 49);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 1, 86466);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 2, 20937);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 4, 3734);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 8, 11128);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 16, 58220);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 32, 33902);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 64, 5707);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 128, 3308);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 256, 1149);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 512, 413);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 1024, 40);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 2048, 25);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 4096, 12);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 8192, 7);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 16384, 4);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 32768, 0);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (399, 2359907137, 1, 2652584166, 65536, 1);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 1, 88335);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 2, 24658);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 4, 4024);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 8, 11678);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 16, 61227);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 32, 35252);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 64, 5821);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 128, 3316);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 256, 1158);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 512, 421);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 1024, 41);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 2048, 25);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 4096, 12);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 8192, 7);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 16384, 4);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 32768, 0);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (400, 2359907137, 1, 2652584166, 65536, 1);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 1, 89498);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 2, 24811);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 4, 4050);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 8, 11919);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 16, 62776);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 32, 36157);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 64, 5993);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 128, 3424);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 256, 1181);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 512, 427);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 1024, 41);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 2048, 25);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 4096, 12);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 8192, 7);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 16384, 4);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 32768, 0);
    Insert into STATS$EVENT_HISTOGRAM (SNAP_ID, DBID, INSTANCE_NUMBER, EVENT_ID, WAIT_TIME_MILLI, WAIT_COUNT)
     Values (401, 2359907137, 1, 2652584166, 65536, 1);
    COMMIT;
    Create STATS$ snapshot table:
    CREATE TABLE STATS$SNAPSHOT
    (
      SNAP_ID               NUMBER,
      DBID                  NUMBER,
      INSTANCE_NUMBER       NUMBER,
      SNAP_TIME             DATE,
      STARTUP_TIME          DATE,
      SESSION_ID            NUMBER,
      SERIAL#               NUMBER,
      SNAP_LEVEL            NUMBER,
      UCOMMENT              VARCHAR2(160 BYTE),
      EXECUTIONS_TH         NUMBER,
      PARSE_CALLS_TH        NUMBER,
      DISK_READS_TH         NUMBER,
      BUFFER_GETS_TH        NUMBER,
      SHARABLE_MEM_TH       NUMBER,
      VERSION_COUNT_TH      NUMBER,
      SEG_PHY_READS_TH      NUMBER,
      SEG_LOG_READS_TH      NUMBER,
      SEG_BUFF_BUSY_TH      NUMBER,
      SEG_ROWLOCK_W_TH      NUMBER,
      SEG_ITL_WAITS_TH      NUMBER,
      SEG_CR_BKS_RC_TH      NUMBER,
      SEG_CU_BKS_RC_TH      NUMBER,
      SEG_CR_BKS_SD_TH      NUMBER,
      SEG_CU_BKS_SD_TH      NUMBER,
      SNAPSHOT_EXEC_TIME_S  NUMBER,
      ALL_INIT              VARCHAR2(5 BYTE),
      BASELINE              VARCHAR2(1 BYTE)
    );
    Load my data in the snapshot table $ STATS:
    Insert into STATS$SNAPSHOT
       (SNAP_ID, DBID, INSTANCE_NUMBER, SNAP_TIME, STARTUP_TIME, 
        SESSION_ID, SERIAL#, SNAP_LEVEL, EXECUTIONS_TH, PARSE_CALLS_TH, 
        DISK_READS_TH, BUFFER_GETS_TH, SHARABLE_MEM_TH, VERSION_COUNT_TH, SEG_PHY_READS_TH, 
        SEG_LOG_READS_TH, SEG_BUFF_BUSY_TH, SEG_ROWLOCK_W_TH, SEG_ITL_WAITS_TH, SEG_CR_BKS_RC_TH, 
        SEG_CU_BKS_RC_TH, SNAPSHOT_EXEC_TIME_S, ALL_INIT)
     Values
       (396, 2359907137, 1, TO_DATE('02/09/2012 13:32:26', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('01/05/2012 20:33:22', 'MM/DD/YYYY HH24:MI:SS'), 
        0, 0, 7, 100, 1000, 
        1000, 10000, 1048576, 20, 1000, 
        10000, 100, 100, 100, 1000, 
        1000, 21.92, 'FALSE');
    Insert into STATS$SNAPSHOT
       (SNAP_ID, DBID, INSTANCE_NUMBER, SNAP_TIME, STARTUP_TIME, 
        SESSION_ID, SERIAL#, SNAP_LEVEL, EXECUTIONS_TH, PARSE_CALLS_TH, 
        DISK_READS_TH, BUFFER_GETS_TH, SHARABLE_MEM_TH, VERSION_COUNT_TH, SEG_PHY_READS_TH, 
        SEG_LOG_READS_TH, SEG_BUFF_BUSY_TH, SEG_ROWLOCK_W_TH, SEG_ITL_WAITS_TH, SEG_CR_BKS_RC_TH, 
        SEG_CU_BKS_RC_TH, SNAPSHOT_EXEC_TIME_S, ALL_INIT)
     Values
       (397, 2359907137, 1, TO_DATE('02/09/2012 14:02:39', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('01/05/2012 20:33:22', 'MM/DD/YYYY HH24:MI:SS'), 
        0, 0, 7, 100, 1000, 
        1000, 10000, 1048576, 20, 1000, 
        10000, 100, 100, 100, 1000, 
        1000, 70.49, 'FALSE');
    Insert into STATS$SNAPSHOT
       (SNAP_ID, DBID, INSTANCE_NUMBER, SNAP_TIME, STARTUP_TIME, 
        SESSION_ID, SERIAL#, SNAP_LEVEL, EXECUTIONS_TH, PARSE_CALLS_TH, 
        DISK_READS_TH, BUFFER_GETS_TH, SHARABLE_MEM_TH, VERSION_COUNT_TH, SEG_PHY_READS_TH, 
        SEG_LOG_READS_TH, SEG_BUFF_BUSY_TH, SEG_ROWLOCK_W_TH, SEG_ITL_WAITS_TH, SEG_CR_BKS_RC_TH, 
        SEG_CU_BKS_RC_TH, SNAPSHOT_EXEC_TIME_S, ALL_INIT)
     Values
       (398, 2359907137, 1, TO_DATE('02/09/2012 14:35:03', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('01/05/2012 20:33:22', 'MM/DD/YYYY HH24:MI:SS'), 
        0, 0, 7, 100, 1000, 
        1000, 10000, 1048576, 20, 1000, 
        10000, 100, 100, 100, 1000, 
        1000, 14.28, 'FALSE');
    Insert into STATS$SNAPSHOT
       (SNAP_ID, DBID, INSTANCE_NUMBER, SNAP_TIME, STARTUP_TIME, 
        SESSION_ID, SERIAL#, SNAP_LEVEL, EXECUTIONS_TH, PARSE_CALLS_TH, 
        DISK_READS_TH, BUFFER_GETS_TH, SHARABLE_MEM_TH, VERSION_COUNT_TH, SEG_PHY_READS_TH, 
        SEG_LOG_READS_TH, SEG_BUFF_BUSY_TH, SEG_ROWLOCK_W_TH, SEG_ITL_WAITS_TH, SEG_CR_BKS_RC_TH, 
        SEG_CU_BKS_RC_TH, SNAPSHOT_EXEC_TIME_S, ALL_INIT)
     Values
       (399, 2359907137, 1, TO_DATE('02/09/2012 17:02:22', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('02/09/2012 15:24:06', 'MM/DD/YYYY HH24:MI:SS'), 
        0, 0, 7, 100, 1000, 
        1000, 10000, 1048576, 20, 1000, 
        10000, 100, 100, 100, 1000, 
        1000, 15.92, 'FALSE');
    Insert into STATS$SNAPSHOT
       (SNAP_ID, DBID, INSTANCE_NUMBER, SNAP_TIME, STARTUP_TIME, 
        SESSION_ID, SERIAL#, SNAP_LEVEL, EXECUTIONS_TH, PARSE_CALLS_TH, 
        DISK_READS_TH, BUFFER_GETS_TH, SHARABLE_MEM_TH, VERSION_COUNT_TH, SEG_PHY_READS_TH, 
        SEG_LOG_READS_TH, SEG_BUFF_BUSY_TH, SEG_ROWLOCK_W_TH, SEG_ITL_WAITS_TH, SEG_CR_BKS_RC_TH, 
        SEG_CU_BKS_RC_TH, SNAPSHOT_EXEC_TIME_S, ALL_INIT)
     Values
       (400, 2359907137, 1, TO_DATE('02/09/2012 17:32:21', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('02/09/2012 15:24:06', 'MM/DD/YYYY HH24:MI:SS'), 
        0, 0, 7, 100, 1000, 
        1000, 10000, 1048576, 20, 1000, 
        10000, 100, 100, 100, 1000, 
        1000, 2.77, 'FALSE');
    Insert into STATS$SNAPSHOT
       (SNAP_ID, DBID, INSTANCE_NUMBER, SNAP_TIME, STARTUP_TIME, 
        SESSION_ID, SERIAL#, SNAP_LEVEL, EXECUTIONS_TH, PARSE_CALLS_TH, 
        DISK_READS_TH, BUFFER_GETS_TH, SHARABLE_MEM_TH, VERSION_COUNT_TH, SEG_PHY_READS_TH, 
        SEG_LOG_READS_TH, SEG_BUFF_BUSY_TH, SEG_ROWLOCK_W_TH, SEG_ITL_WAITS_TH, SEG_CR_BKS_RC_TH, 
        SEG_CU_BKS_RC_TH, SNAPSHOT_EXEC_TIME_S, ALL_INIT)
     Values
       (401, 2359907137, 1, TO_DATE('02/09/2012 18:02:21', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('02/09/2012 15:24:06', 'MM/DD/YYYY HH24:MI:SS'), 
        0, 0, 7, 100, 1000, 
        1000, 10000, 1048576, 20, 1000, 
        10000, 100, 100, 100, 1000, 
        1000, 1.72, 'FALSE');
    COMMIT;

    Hello

    Sky13 wrote:
    OK I got it to work,

    I'm glad that you guessed it work. When I tried to run your query later, I got an error. On line 7, I think you meant

     when lag(SS.STARTUP_TIME) over (order by SS.SNAP_ID) !=  SS.STARTUP_TIME then 'YES'
    

    This site do not display the <>inequality operator. When you post here, always use the other, equivalent more!, =.
    When I fix it, I don't get 'no rows selected '.

    but it's ugly! Any ideas on simplification it?

    It's a little shorter, but still pretty ugly:

    WITH     got_wait_time_grp    AS
    (
         SELECT     snap_id
         ,     wait_count
         ,     CASE
                  WHEN  wait_time_milli <= 7
                  THEN  '<= 7'
                  ELSE  '> 7'
              END     AS wait_time_grp
         FROM    stats$event_histogram
         WHERE     event_id     = 2652584166
    )
    ,     grouped_data     AS
    (
         SELECT       ss.snap_id
         ,       ss.snap_time
         ,       eh.wait_time_grp
         ,       CASE
                    WHEN  ss.startup_time != LAG (ss.startup_time) OVER ( PARTITION BY  eh.wait_time_grp
                                                                              ORDER BY         ss.snap_id
                                                   )
                    THEN  'YES'
                    ELSE  'NO'
                END                              AS db_restart
         ,       SUM (eh.wait_count) - LAG ( SUM (eh.wait_count)
                                             , 1
                                 , 0
                                 ) OVER ( PARTITION BY  ss.startup_time
                                             ,                    eh.wait_time_grp
                                             ORDER BY          ss.snap_id
                                     )              AS wait_dif
         ,       DENSE_RANK () OVER (ORDER BY ss.snap_id)     AS dr
         FROM      stats$snapshot      ss
         ,       got_wait_time_grp       eh
         WHERE       ss.snap_id           = eh.snap_id
         AND       ss.snap_id           BETWEEN 396
                                AND      401
         GROUP BY  GROUPING SETS ( (ss.snap_id, ss.snap_time, ss.startup_time, eh.wait_time_grp)
                                   , (ss.snap_id, ss.snap_time, ss.startup_time)
                        )
    )
    SELECT       snap_id, snap_time, db_restart
    ,       MIN (CASE WHEN wait_time_grp = '<= 7' THEN wait_dif END)     AS wait_count_le_7ms
    ,       MIN (CASE WHEN wait_time_grp = '> 7'  THEN wait_dif END)     AS wait_count_gt_7ms
    ,       MIN (CASE WHEN wait_time_grp IS NULL  THEN wait_dif END)     AS total_wait_count
    ,       MIN (CASE WHEN wait_time_grp = '<= 7' THEN wait_dif END) * 100
         / MIN (CASE WHEN wait_time_grp IS NULL  THEN wait_dif END)     AS wait_count_percent_le_7ms
    ,       MIN (CASE WHEN wait_time_grp = '> 7'  THEN wait_dif END) * 100
         / MIN (CASE WHEN wait_time_grp IS NULL  THEN wait_dif END)     AS wait_count_percent_gt_7ms
    FROM       grouped_data
    WHERE       dr     > 1
    GROUP BY  snap_id, snap_time, db_restart
    ORDER BY  snap_id
    ;
    

    Output:

    `                                                        WAIT_   WAIT_
                                     WAIT_   WAIT_          COUNT_  COUNT_
                             DB_    COUNT_  COUNT_  TOTAL_ PERCENT PERCENT
    SNAP                     RE        LE_     GT_   WAIT_    _LE_    _GT_
     _ID SNAP_TIME           START     7MS     7MS   COUNT     7MS     7MS
    ---- ------------------- ----- ------- ------- ------- ------- -------
     397 2/9/2012 2:02:39 PM NO       3311   16261   19572   16.92   83.08
     398 2/9/2012 2:35:03 PM NO      10040   11499   21539   46.61   53.39
     399 2/9/2012 5:02:22 PM YES    111137  113916  225053   49.38   50.62
     400 2/9/2012 5:32:21 PM NO       5880    5047   10927   53.81   46.19
     401 2/9/2012 6:02:21 PM NO       1342    3004    4346   30.88   69.12
    
  • 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.

  • 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

Maybe you are looking for