"create columns with a where clause" in BMM

Hi All,
I have a question about OBI EE Meta data layer.
We have OBIEE sitting on a Data Warehouse with a star schema.
Our Fact table holds the following fields...
EmployeeID
CompanyID
Measure ID
Measure Name
MEASURE
This is what we have in the physical layer, BMM layer and the presentation layer but I want to be able to "create columns with a where clause"
So my fact table in the presentation layer would look like this
Amount Sold
Unit Cost
Company Amount
I thought I could just create a logical column with
Amount Sold = Measure
where Measure Name = "Amount Sold"
But I can't seem to find any to do that.
Any ideas?
Thanks

Or you simply map your measure in the Logical Table source as something like :
CASE WHEN MEASURE_NAME = 'Amount Sold' THEN MEASURE ELSE 0 END.
You need to decide if you want the where clause adding in the Logical table source (be careful you will need a seperate LTS for each measure, this will mean more than one SQL being fired when you have more than one measure in the report).
Or you go with this case method on each measure, be able to have all the measures mapped in 1 LTS, include all those in the report and they will be retrieved by one SQL block.

Similar Messages

  • How to create a procedure to output REF CURSOR with any WHERE clause?

    I have an requirement like this: I have huge query which need to reuse in my code more than 10 times. This SQL has about 50 lines. Thing is for those 10 odd times sometimes the WHERE clause changes (columns are the same). So I cannot create a view since SQL is not static.
    I thought of writing a procedure with a WHERE_CLAUSE input para. I output a sys refcursor by adding the where clause. But I can't do it since you cannot add a where clause like that.
    i.e.
    PROCEDURE dynamyic_query (p_where_clause IN VARCHAR2, p_out_query OUT SYS_REFCURSOR ) IS
    BEGIN
      OPEN p_out_query FOR SELECT ......... FROM table WHERE || ' ' || p_where_clause;
    END;The above gives error.
    How to handle a situation like this???? Any help would be greatly appreciated.

    I tried this method:
    I created a table tab_test which has these records:
    TNAME                          TABTYPE    CLUSTERID                                                                                                                                                                  
    ABS_V4_P_ERROR_MESSAGES        TABLE                                                                                                                                                                                  
    ABS_V4_P_ORG_PARAM             TABLE                                                                                                                                                                                  
    ABS_V4_P_PARAMETER             TABLE                                                                                                                                                                                  
    ABS_V4_P_SYS_PARAM             TABLE                                                                                                                                                                                  
    ACCINTERFACE_PARAMETERS        TABLE                                                                                                                                                                                  
    ACCOUNTS                       TABLE                                                                                                                                                                                  
    ACCOUNT_EXTRACT_PERIODS        TABLE                                                                                                                                                                                  
    ACCOUNT_EXTRACT_PERIODS#       TABLE                                                                                                                                                                                  
    ACCOUNT_EXTRACT_PERIODS_1      TABLE                                                                                                                                                                                   Now I create this proc:
    PROCEDURE FORMS_TEXT_DYN_SQL_TEST(p_where_cluase IN VARCHAR2, p_out_cursor OUT SYS_REFCURSOR) IS
      v_stmt VARCHAR2(1000);
    BEGIN
      v_stmt := 'SELECT tname FROM tab_test WHERE tname LIKE ''%ABS_V4%'' AND tabtype = :x';
      OPEN p_out_cursor FOR v_stmt using p_where_cluase;
    END;I create this code block and run it:
    declare
      v_tname varchar2(200);
      out_cursor sys_refcursor;
    begin
      forms_text_dyn_sql_test('TABLE', out_cursor );
      LOOP
        fetch out_cursor INTO v_tname;
        exit when out_cursor%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(v_tname);
      END LOOP;
    end;
    /I get correct output:
    ABS_V4_P_ERROR_MESSAGES
    ABS_V4_P_ORG_PARAM
    ABS_V4_P_PARAMETER
    ABS_V4_P_SYS_PARAMHowever, when I change the proc like this:
    PROCEDURE FORMS_TEXT_DYN_SQL_TEST(p_where_cluase IN VARCHAR2, p_out_cursor OUT SYS_REFCURSOR) IS
      v_stmt VARCHAR2(1000);
    BEGIN
      v_stmt := 'SELECT tname FROM tab_test WHERE tname LIKE ''%ABS_V4%'' AND :y';
      OPEN p_out_cursor FOR v_stmt using p_where_cluase;
    END;And run this code block:
    declare
      v_tname varchar2(200);
      out_cursor sys_refcursor;
    begin
      forms_text_dyn_sql_test(' 1 = 1 ', out_cursor );
      LOOP
        fetch out_cursor INTO v_tname;
        exit when out_cursor%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(v_tname);
      END LOOP;
    end;
    /I get error:
    [1]: (Error): ORA-00920: invalid relational operator ORA-06512: at "ABS.FORMS_TEXT_DYN_SQL_TEST", line 6 ORA-06512: at line 5Looks like you can only put column_name = :z, column_name = :y type values. You cannot it seems replace it with any WHERE CLAUSE????

  • Problem with column alias: Unknown column 'avg_rating' in 'where clause'

    Hello,
    I have a basic sql statement as follows:
    SELECT
    e.establishment_id,
    e.establishment_name,
    avg(r.rating) avg_rating
    FROM
    establishment e,
    rating r,
    comment com,
    establishment_country ec,
    country_ref cou
    where
    etc...
    and avg_rating >= 1
    and 0=0
    group by e.establishment_id
    order by e.establishment_idI have used a column alias for "avg(r.rating)" and named it "avg_rating".
    It works in my Mysql Query browser without problem but when I run it from Java I get this:
    java.sql.SQLException: Unknown column 'avg_rating' in 'where clause'
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:2988)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:2917)
        at com.mysql.jdbc.Statement.executeQuery(Statement.java:824)
        at org.jboss.resource.adapter.jdbc.WrappedStatement.executeQuery(WrappedStatement.java:145)
        at arcoiris.SearchSessionBean.performSearch(SearchSessionBean.java:73)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
        at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
        at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:149)
        at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:154)
        at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:54)
        at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
        at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
        at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
        at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
        at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:153)
        at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
        at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
        at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
        at org.jboss.ejb.Container.invoke(Container.java:873)
        at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:415)
        at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:88)
        at $Proxy172.performSearch(Unknown Source)
        at arcoiris.SearchManagedBean.performSearch(SearchManagedBean.java:171)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
        at javax.faces.component.UICommand.broadcast(UICommand.java:312)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
        at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
        at java.lang.Thread.run(Thread.java:595)Can anyone help please?
    Thanks in advance,
    Julien Martin.

    I am having the similiar problem, the query in java creator IDE works fine after i upgraded the J-connector and changed DataSource type for MySQL to mysql-connector-java-5.0.4-bin.jar. but still i cannot bind any control in the form to the aliased column. this is really frustrating. can anyone from Sun Developer explain?
    THX

  • Where clause in BMM (logical table Source) is not working

    Hello Folks ,
    I felt I ask here before I ask Siebel(oops Oracle!) support, by which I could save significant time NOT restart box multiple times , change log level , upload RPD , making multiple screen shots etc.. etc..
    Here is an example the scenario
    I have a custom field in the activity called the Activity source with two digit abbreviation
    TX – Text message
    LT – Letter
    EM – Email so forth
    The LOV table W_LOV_D has the type as CUST_SRC_ACT
    Whoever implemented analytics they did an alias table for W_LOV_D and did a physical join between W_ACTICITY_F to W_LOV_D through field VAL
    W_ACTICITY_F.X_ACT_SRC--> W_LOV_D.VAL and they did not do a where clause in BMM to retrieve only W_LOV_D.TYPE =’CUST_SRC_ACT’
    So in fact the query pulls TX for CUST_SRC_ACT as well as TX for State abbreviation
    I went ahead and added the where clause filter
    "Siebel Data Warehouse".Catalog.dbo."Dim_W_LOV_D_Acty_Src".TYPE = 'CUST_SRC_ACT'
    I saved the repository and started the server (I was doing offline) spooled the SQL and the results are the same. Looks like the filter is not being applied.
    I did reload the server meta data etc..
    Would anyone knows what is going on with the filter (or what I am doing wrong)?
    Thanks in advance,
    AP

    hi Ap,
    Pull only Dim_W_LOV_D_Acty_Src column into answers and check whether u r able to see CUST_SRC_ACT or not .Of course, you need to check sql query too
    Thanks,
    Saichand.v

  • Using SAMPLE with a WHERE clause

    (Oracle 9iR2)
    I am using the SAMPLE keyword in a SELECT statement with a WHERE clause. Is the sample extracted before or after applying the WHERE clause?
    For example, if I have the statement:
    SELECT emp_id FROM employees SAMPLE(10)
    WHERE salary > 50000;
    Does the database first extract a 10% sample of all the rows and then apply the salary filter on the sample (meaning it's possible that no rows are returned even though there are rows with salary > 50000)? Or does it return a 10% sample of the rows that meet the filter condition (meaning rows will always be returned as long as there are rows with salary > 50000)?

    The sample is extracted before the where clause:
    SQL> drop table sample_test;
    Table dropped.
    SQL> create table sample_test (id number, salary number);
    Table created.
    SQL>
    SQL> begin
    2 for i in 1..99 loop
    3 insert into sample_test values (i, 100);
    4 end loop;
    5
    6 insert into sample_test values (100, 1000);
    7 end;
    8 /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> commit;
    Commit complete.
    SQL>
    SQL> select * from sample_test sample(5)
    2 where salary > 100;
    no rows selected

  • Insert Row is visible in other VO with excluded where-clause

    Hi,
    i found something that makes me a little bit confusing about ADF BC...
    TestCase:
    Env:
    JDev 10.1.2     
    HR Schema / Table "regions"
    All Objects created ´by ADF BC Wizards
    - ViewObject A and ViewObject B based on Entity "Regions"
         - ViewObject A with WHERE-CLAUSE region_id=10 at DesignTime
    - ViewObject B with NO WHERE-CLAUSE (select * from regions)
    JUnitTest:
    public void testInsertRow()
    ViewObject viewA = fixture1.getApplicationModule().findViewObject("RegionsAView");
    ViewObject viewB = fixture1.getApplicationModule().findViewObject("RegionsBView");
    System.out.println("ViewA:"+viewA.getRowCount()); //-->0
    assertTrue("Must 0 ! region_id = 10",viewA.getRowCount() == 0);
    Row row = viewB.createRow();
    row.setAttribute("RegionId",new Number(99));
    row.setAttribute("RegionName","NRW");
    viewB.insertRow(row);
    System.out.println("ViewB:"+viewB.getRowCount()); // -> 5
    System.out.println("ViewA:"+viewA.getRowCount()); // -> 1
    //this assert failt !
    assertTrue("Must 0 ! where clause is region_id = 10 and insert region_id was 99 ",viewA.getRowCount() == 0);
    Is this a bug or feature ? Can anybody explain that behavior ? thx :)
    uli

    See this article on my blog for an explanation and a code sample for how to gain more fine-grained control over this View Link Consistency feature...
    http://radio.weblogs.com/0118231/2004/02/27.html#a242

  • REPORT with dynamic WHERE CLAUSE (run RDF or REP) ?

    Hi:
    When running a REPORT (myreport.rep) with dynamic where clause using a lexical parameter, I got this error:
    REP-1439: Cannot compile .REP or .PLX file as it does not have source
    If i run the report specifiying RDF extension (myreport.rdf) the report run successfully! Is this normal ?
    If I specify RDF extension will Report Server COMPILE the report everytime I execute it ?
    When using dynamic WHERE CLAUSE I will have to run RDF files instead of REP ?
    I'm running Reports 9i under Linux, with IDS under Windows.
    Waiting Help
    Joao Oliveira

    It sounds like you are building the .rep files on one platform (windows) and running them on another (linux). The reason that the .rdf file continues to work is that Reports recompiles the PL/SQL within the report when you move from one platform to another or change schemas. .rep files can't be re-compiled in this way so you need to ensure they are compiled successfully when converting them.
    You need to convert from .rdf to .rep on the platform that you are intending to run on. Try running rwconverter on the linux platform with "compile_all=yes" to produce the .rep file and running that .rep file.

  • "Invalid Column" on multiple where clauses with subqueries and cfqueryparam

    I'm seeing a behavior in the coldfusion cfquery that I'd like to find an exmplanation for .  I've got a query that does a subquery in the select portion and if I have multiple where lines, I get an "invalid column name" message for my second where clause, but only when I'm using cfqueryparam
    For example on the following I get "Invalid column name 'position_id'"
    SELECT   department_staff_tbl.*,
             (   SELECT   max(bookmark_id)
                 FROM     bookmarked_items_tbl
                 WHERE    item_id = department_staff_tbl.staff_id
             ) AS bookmark_id
    FROM     department_staff_tbl
    WHERE    department_id = <cfqueryparam value="#arguments.deptid#"  cfsqltype="cf_sql_integer">
    AND     position_id   = <cfqueryparam value="#arguments.posid#"   cfsqltype="cf_sql_integer">
    AND     staff_id      = <cfqueryparam value="#arguments.staffid#" cfsqltype="cf_sql_integer">
    If I change the order of my where clause so staff_id is first, then it tells me "department_id" is an invalid column.
    If I only have one where clause, it works.  (i.e. WHERE position_id = <cfqueryparam value="#arguments.posid#" cfsqltype="cf_sql_integer">).
    If I remove the where clause from my subquery (WHERE     item_id = department_staff_tbl.staff_id) it works.
    It also works if I remove the cfqueryparam from my where clause so that my query looks like this:
    SELECT   department_staff_tbl.*,
             (   SELECT   max(bookmark_id)
                 FROM     bookmarked_items_tbl
                 WHERE    item_id = department_staff_tbl.staff_id
             ) AS bookmark_id
    FROM     department_staff_tbl
    WHERE    department_id = #arguments.deptid#
    AND     position_id   = #arguments.posid#
    AND     staff_id      = #arguments.staffid#
    Any thoughts?

    I see two tables. So can the server. So, use qualified column-names.
    SELECT   department_staff_tbl.*,
             (   SELECT   max(bookmarked_items_tbl.bookmark_id)
                 FROM     bookmarked_items_tbl
                 WHERE    bookmarked_items_tbl.item_id = department_staff_tbl.staff_id
             ) AS bookmark_id
    FROM     department_staff_tbl
    WHERE    department_staff_tbl.department_id = <cfqueryparam value="#arguments.deptid#"  cfsqltype="cf_sql_integer">
    AND      department_staff_tbl.position_id   = <cfqueryparam value="#arguments.posid#"   cfsqltype="cf_sql_integer">
    AND      department_staff_tbl.staff_id      = <cfqueryparam value="#arguments.staffid#" cfsqltype="cf_sql_integer">

  • Query SQL datastore with XML where clause source

    Hope I am in the right place.  New to Bus Obj Data Services Designer....I have cerated xml schemas, added it to the page as an xml source in.  Mapped a test xml file and all is well there.  I have added a query that grabs the xml.
    I need to then query the MS SQL datastore ans use  the data form the xml query as the where clause.  How is this done?  Or do I put a query on the datastore for all the data in a table then do anotehr query filtering one with the other?  seems like that would be rather heavy and low performance.  The results will then be sent back out as xml (schema and test file already set up as an xml out)
    Thanks!

    Thanks for the tips.
    I'm trying to implement this option, using your ViewDefHelper.
    I´m running into a problem though. After I create my dynamic View Object using a ViewDef, I need to create some view links.
    So I get the AttributeDefs of the columns (source, and destination) from the method findAttributeDef (which is the whole purpose of performance in my post). This method is returning the correct Attribute Def, but when I create the view Link with the method createViewLinkBetweenViewObjects(java.lang.String vlName,
    java.lang.String accessorName,
    ViewObject master,
    AttributeDef[] srcAttrs,
    ViewObject detail,
    AttributeDef[] destAttrs,
    java.lang.String assocClause)
    My destination query is generating the where clause as:
    null = ?
    Any Ideas what I'm doing wrong ?
    Thanks again.
    John.

  • Referencing Aggregated Column Value in Where Clause

    Hello -
    I'm trying to determine how I can accomplish the following in the most straightforward, efficient way.
    Among other things, I'm selecting the following value from my table:
    max(received_date) as last_received_dateI also need to evaluate the "last_received_date" value as a condition in my where clause. However, I can't reference my aliased "last_received_date" column value, and when I try to evaluate max(received_date) in the where clause, I get the "group function is not allowed here" error.
    Does anyone know of a good workaround?
    Thanks,
    Christine

    Hi,
    Column aliases can be used in the ORDER BY clause: aside from that, they cannot be used in the same query where they are defined. The workarounds are
    (a) define the alias in a sub-query, and use it in a super-query, like Someoneelse did, or
    (b) repeat the aliased expression, as in the HAVING-clause, below.
    Aggregate functions are computed after the WHERE-clause. (That explains why you can do things like
    SELECT  MAX (received_date) last_received_date_2008
    FROM    table_x
    WHERE   TO_CHAR (received_date, 'YYYY')  = '2008';).
    The HAVING-clause is like the WHERE-clause, but it is applied after the aggregate functions are computed, e.g.
    SELECT    deptno
    ,         MAX (recieved_date)  AS last_received_date
    FROM      table_x
    GROUP BY  deptno
    HAVING    MAX (received_date)    > SYSDATE - 7   -- Only show deptartments with activity in the last week
    ;

  • A somewhat more complex use of EXECUTE_QUERY with a Where clause...

    Basically, what I need to be able to do is when the form receives a certain parameter upon opening; it must immediately run a certain query and populate the data blocks.
    I do understand the concept of setting the DEFAULT_WHERE in the PRE_QUERY trigger for the block; but I don't think this will work in my situation.
    The reason being is that each data block must run 2 separate queries; and BOTH resulting queries must be populated to each data block, and not overwrite eachother...
    Not only that, but the query being executed requires me to reference 2 separate tables (the data coming from one, however its comparing results from 2 separate tables, so I don't think simply modifying the where clause for the data block will even be possible to achieve the results I am looking for.
    Maybe further explanation of my queries may help the situation. Basically, each data block is linked to a table for the current logged in user, and then there is a production table as well. When ANYTHING is modified, added, or deleted on the current user's table, they are suppose to "publish" the record to the production table. The EXECUTE_QUERY statement will be responsible for running the query that will populate ALL the records that have yet to be published to the production table. So basically, its running a query that will use an ID and compare each individual field by that ID for any changes from the production table. Then, it runs another query to find records that are in either the production table or user table, and not the other; to flag a new record or deleted record.
    I've been thinking about possible ways to do this, but have had no luck unfortunately;
    ANY guidance will be greatly appreciated it. I do understand that my description of the problem may be hard to comprehend, so if you need further clarification please ask.
    Jason
    Message was edited by:
    user558647

    It would be helpful to give an example of the sort of data in each table and what you want to show in each block. I probably didn't understand most of what you wrote but I think the following may be analogous to your situation and requirements (but you'll have more columns of course):
    SQL> CREATE TABLE t_user AS
      2    SELECT
      3      ROWNUM id,
      4      object_name col1,
      5      object_type col2
      6    FROM all_objects
      7    WHERE ROWNUM < 10;
    Table created.
    SQL>
    SQL> DELETE FROM t_user WHERE id = 1;
    1 row deleted.
    SQL>
    SQL> CREATE TABLE t_published AS
      2    SELECT
      3      ROWNUM id,
      4      CASE Mod(ROWNUM,2)
      5        WHEN 0 THEN SubStr(object_name,1,2)
      6        ELSE object_name
      7        END AS col1,
      8      object_type col2
      9    FROM all_objects
    10    WHERE ROWNUM < 9;
    Table created.
    SQL>
    SQL>
    SQL> SELECT * FROM t_user;
            ID COL1                           COL2
             2 I_USER1                        INDEX
             3 CON$                           TABLE
             4 UNDO$                          TABLE
             5 C_COBJ#                        CLUSTER
             6 I_OBJ#                         INDEX
             7 PROXY_ROLE_DATA$               TABLE
             8 I_IND1                         INDEX
             9 I_CDEF2                        INDEX
    8 rows selected.
    SQL> SELECT * FROM t_published;
            ID COL1                           COL2
             1 ICOL$                          TABLE
             2 I_                             INDEX
             3 CON$                           TABLE
             4 UN                             TABLE
             5 C_COBJ#                        CLUSTER
             6 I_                             INDEX
             7 PROXY_ROLE_DATA$               TABLE
             8 I_                             INDEX
    8 rows selected.
    SQL>
    SQL> -- yet to be published to the production table
    SQL> -- includes records previously published and then updated, but not new
    SQL> -- records which have never been published (these are in the other query)
    SQL> SELECT u.id, u.col1, u.col2
      2  FROM t_user u, t_published p
      3  WHERE u.id = p.id
      4  AND (
      5    u.col1 != p.col1
      6    OR u.col2 != p.col2
      7    )
      8  ;
            ID COL1                           COL2
             2 I_USER1                        INDEX
             4 UNDO$                          TABLE
             6 I_OBJ#                         INDEX
             8 I_IND1                         INDEX
    SQL>
    SQL> -- new and deleted records
    SQL> SELECT * FROM(
      2    SELECT id, col1, col2, 'NEW' status FROM t_user
      3    UNION ALL
      4    SELECT id, col1, col2, 'DELETED' status FROM t_published
      5  )
      6  WHERE id NOT IN(
      7    SELECT id FROM t_user
      8    INTERSECT
      9    SELECT id FROM t_published
    10  )
    11  ;
            ID COL1                           COL2                STATUS
             9 I_CDEF2                        INDEX               NEW
             1 ICOL$                          TABLE               DELETED
    SQL> Basically, I think the answer is in the query and not the Where Clause.
    I think you want one of these queries in each block, so set the blocks' queries (are you changing that query based on the parameter passed in, or just executing the query, you're not clear on that) and then do
    go_block('B2');
    execute_query;
    go_block('B1');
    execute_query;

  • Dynamic itab with Dynamic Where clause

    Hi, Dear All,
    Can someone provide a code extract for Dynamic where clause, i had already done with dynamic itab for a given set of fields, and i need to add where clause dynamically for a given field for a given range of values.
    select (i_fields) into table <dyn_table>
                      from (p_table)
                     where (v_where).
    In the above except the where clause, everything is done. Please help me.
    with best regards
    Mahesh

    Hi,
    here is the code extract for your reference.Pl. correct me.
    with regards
    REPORT  Z_DYN_ITAB                              .
    TYPE-POOLS: SLIS.
    DATA:NAME(100) TYPE C.
    TYPES: BEGIN OF ITAB_TYPE,
            WORD(20),
          END   OF ITAB_TYPE.
    DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE WITH HEADER LINE.
    DATA: vg_fields(255) TYPE c,
          i_fields LIKE TABLE OF vg_fields.
    DATA: it_fcat TYPE slis_t_fieldcat_alv,
          is_fcat LIKE LINE OF it_fcat,
          ls_layout TYPE slis_layout_alv.
    DATA: it_fieldcat TYPE lvc_t_fcat,
          is_fieldcat LIKE LINE OF it_fieldcat.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <dyn_field>.
    data: dy_table type ref to data.
    data: dy_line type ref to data,
          xfc type lvc_s_fcat.
    DATA: v_where TYPE string, " Variable for storing where clause.
          v_dynamic(18) TYPE c, "variable to store select option datatype
          o_field TYPE REF TO cx_root," object to catch exception
          text TYPE string. "string variable to store exception text.
    CONSTANTS: c_var(15) TYPE c VALUE ' IN S_RANGE'.
    selection-screen begin of block b1 with frame.
    parameters: p_table(30) type c default 'T001',
                p_name(100) type c,
                p_field(10) TYPE c. " Parameter to capture field name.
    SELECT-OPTIONS: s_range FOR v_dynamic. " Select-option for range.
    selection-screen end of block b1.
    start-of-selection.
    NAME = p_name.
    SPLIT NAME AT ',' INTO TABLE ITAB.
    LOOP AT ITAB.
    is_fcat-fieldname = itab-word.
    is_fcat-tabname = p_table.
    APPEND is_fcat to it_fcat.
    ENDLOOP.
    LOOP AT it_fcat INTO is_fcat.
      is_fieldcat-fieldname = is_fcat-fieldname.
      is_fieldcat-tabname = is_fcat-tabname.
      APPEND is_fieldcat TO it_fieldcat.
      CONCATENATE is_fieldcat-tabname is_fieldcat-fieldname INTO
            vg_fields SEPARATED BY '~'.
      APPEND vg_fields TO i_fields.
    ENDLOOP.
    perform create_dynamic_itab.
    perform get_data.
    Create dynamic internal table and assign to FS
    form create_dynamic_itab.
    call method cl_alv_table_create=>create_dynamic_table
    exporting
    it_fieldcatalog = it_fieldcat
    importing
    ep_table = dy_table.
    assign dy_table->* to <dyn_table>.
    Create dynamic work area and assign to FS
    create data dy_line like line of <dyn_table>.
    assign dy_line->* to <dyn_wa>.
    endform.
    form get_data.
    Select Data from table.
    CONCATENATE p_field c_var INTO v_where.
    TRY.
    select (i_fields) into table <dyn_table>
                      from (p_table)
                     where (v_where).
    if sy-dbcnt = 0.
    write : text-t02.
    endif.
    *Write out data from table.
    Loop at <dyn_table> into <dyn_wa>.
    do.
    assign component sy-index of structure <dyn_wa> to <dyn_field>.
    if sy-subrc <> 0.
      exit.
    endif.
    if sy-index = 1.
      write:/ <dyn_field>.
    else.
      write: <dyn_field>.
    endif.
    enddo.
    endloop.
    Exception Catching.
    CATCH cx_root INTO o_field.
    text = o_field->get_text( ).
    Calling Function to give information message regarding Exception
    CALL FUNCTION 'POPUP_TO_INFORM'
    EXPORTING
    titel = text-t03
    txt1 = text
    txt2 = text-t04.
    TXT3 = ' '
    TXT4 = ' '
    LEAVE TO LIST-PROCESSING.
    ENDTRY.
    endform.

  • Help me out to create column with time format

    Hi all,
    please help me to find the query to Create a table with 3 columns and insert the following data
    ENTITYID| CHGDATE | CHGTIME
    ======= ==================== ========
    4214984| 02-OCT-06 12.00.00.000000 AM | 07:23:57
    4214985| 11-SEP-08 12.00.00.000000 AM | 10:52:19
    and Update the first row of the above table as follows
    4214984 | 02-OCT-06 07.23.57.000000 AM | 07:23:57
    need to update the CHGDATE column with time of CHGTIME column.

    As already said by Hans and Hoek: you should get rid of that chgtime column. Storing information twice only leads to extra storage and the need to keep them both in sync, without any benefit.
    An example which also shows a possible way to only update the time information. Lots of other ways are possible as well.
    SQL> create table entdate
      2  ( entityid number
      3  , chgdate date
      4  )
      5  /
    Tabel is aangemaakt.
    SQL> insert into entdate (entityid,chgdate) values (4214984, to_date('2006-10-02 07:23:57','yyyy-mm-dd hh24:mi:ss'))
      2  /
    1 rij is aangemaakt.
    SQL> insert into entdate (entityid,chgdate) values (4214985, to_date('2008-09-11 10:52:19','yyyy-mm-dd hh24:mi:ss'))
      2  /
    1 rij is aangemaakt.
    SQL> select * from entdate
      2  /
      ENTITYID CHGDATE
       4214984 02-10-2006 07:23:57
       4214985 11-09-2008 10:52:19
    2 rijen zijn geselecteerd.
    SQL> remark
    SQL> remark  "my doubt is how to update only the time in CHGDATE column"
    SQL> remark
    SQL> update entdate
      2     set chgdate = trunc(chgdate) + numtodsinterval(7,'hour') + numtodsinterval (18,'second')
      3   where entityid = 4214984
      4  /
    1 rij is bijgewerkt.
    SQL> select * from entdate
      2  /
      ENTITYID CHGDATE
       4214984 02-10-2006 07:00:18
       4214985 11-09-2008 10:52:19
    2 rijen zijn geselecteerd.Regards,
    Rob.

  • Performance with unspecific where clause

    Hi gurus,
    at the moment I do have a sql statement on a view with an unspecific where clause like
    select from <view> where <textfield> like %whatIsearch%
    The text field is not in the key fields which are used to create the view. An index on <textfield> does not help, because the where clause starts with a %.
    Other databases like Oracle do finish the statement within seconds, maxdb needs minutes.
    I there a possibility to speedup the statement in MaxDB? (Besides telling the user to use better qualified statments.)
    Why is Oracle that fast?
    Thanks for you help.
    Best regards
    Christian G

    > Other databases like Oracle do finish the statement within seconds, maxdb needs minutes.
    > I there a possibility to speedup the statement in MaxDB? (Besides telling the user to use better qualified statments.)
    > Why is Oracle that fast?
    Hi Christian,
    In that case Oracle can take advantage from beeing able to brute-force read many blocks at once (aka multiblock read).
    When we assume that there is an index on the oracle database available, then Oracle will likely decide to read all blocks of that index into the cache and look for matches then. It's called Fast Full Scan.
    It's not a very efficient method to address specific rows, but for this requirement it works well.
    Anyhow, you should be aware that this way of evaluating rows does not scale very well - in fact it get's more expensive with every block the index grows.
    MaxDB cannot easily read all blocks in a row, due to the fact that the pages are mixed over all data volumes. This way of storing data eliminates the need for reorganisations and evens out I/O traffic, but it comes for the price of beeing less performant when people use such unefficient predicates.
    Because of this and the way who indexes work in MaxDB (primary keys instead of rowids), MaxDB does only consider an index access for like conditions that start with a '%' when the query can be answered by only accessing the index (index only access).
    What you may try out to improve the situation is to activate the experimental read-ahead or prefetch feature, which is currently available in MaxDB 7.6. only (not in 7.5 or in 7.7).
    By setting READAHEAD_TABLE_THRESHOLD to a value >0, say 128, MaxDB can choose to
    perform table scans (no index scans!) in parallel with multiple server tasks for all table scans that are expected to pass the threshold (unit here is pages as visible in the execution plan of your statement).
    That way the usertask running the query can work on checking the data in the pages, while the server task load the pages into the cache.
    Another approach would be to have the DB Cache big enough so that most of the table would be found in the cache.
    regards,
    Lars

  • Most efficient way to get row count with a where clause

    Have not found a definitive answer on how to do this.  Is there a better way to get a row count from a large table that needs to satisfy a where clause like so:
    SELECT COUNT(*) FROM BigTable WHERE TypeName = 'ABC'
    I have seen several posts suggesting something like 
    SELECT COUNT(*) FROM BigTable(NOLOCK);
    and 
    selectOBJECT_NAME(object_id),row_count from sys.dm_db_partition_stats
    whereOBJECT_NAME(object_id)='BigTable'but I need the row count that satisfies my where clause (i.e.: WHERE TypeName = 'ABC')

    It needs index to improve the performance. 
    - create index on typename column
    - create a indexed view to do the count in advance
    -partition on type name (although it's unlikely) then get count from the system tables...
    all those 3 solutions are about indexing.
    Regards
    John Huang, MVP-SQL, MCM-SQL, http://www.sqlnotes.info

Maybe you are looking for

  • CATA Sender and receiver are identical

    Hi expert, I have a problem during the transaction CATA. My situation is the follow: I insert a record in CAT2 where I have the same object in both the sender and the receiver field (Cost Center). When i save, the system show a Warning message BK015

  • Default Cache Error on a G4 Quicksilver

    So I've got a G4 quicksilver and it will not boot. I tried all the different ways to get it to boot. Holding "c" with a boot disk, checking the battery, unplugging ram one at a time, etc... The problem is, when I hold "option" to get into the disk bo

  • IPod only connects as Removable Disk (E:) and says "Safely Remove Hardware

    I recently posted about this problem and since then, I have not been able to do a thing. I have done the 5 R's, and still nothing. This is very frustrating, I just want my iPod so update again. The music and videos are still on it but some songs just

  • Space after paragraph "returns"

    Hi! I've made a template so that I don't have to keep telling Pages not to make space after each paragraph, but... Each time I use a style (like Heading) it automaticlly sets the space after a paragraph to 12 pt. This is annoying - can I change it? T

  • How do I reset my security questions when I do not have a rescue email

    Hi guys I have forgotten my answers to the security questions further more I did not provide the rescue email. I have looked all over the stupid support site in order to send them an email since they said that they will have to do it. Please someone