Select with Where not in (subSelect)

Hi,
Is there any special about that 'not' in this ORacle sql (10g) that it doesn't return me any rows, unlike SQLServer with same code:
select count(*) from t1_ups where  id_ups not in (select b.id_ups from t1_dups b)
COUNT(*)              
0
vs.
select count(*) from t1_ups where  id_ups not in ('abc', 'def','xyz')  --select b.id_ups from t1_dups b)
COUNT(*)              
16
DDL:
    "id_ups"            VARCHAR2(20 BYTE),   is the same for both tables.I see that if remove <not> it works fine. is there any OR --> AND converssion happaned with negation?
My global task is to make UNION "with replacement" when if any records exist in id_dups they will replace ones from id_ups, so I try to do it in separate parts.
Thanks
Tr
Edited by: trento on Nov 16, 2010 3:00 PM

trento wrote:
Hi,
Is there any special about that 'not' in Yes, you need to be aware how the syntax reacts to NULL values.
create table in_or_not
  col1  number
TUBBY_TUBBZ?insert into in_or_not values (2);
1 row created.
Elapsed: 00:00:00.05
TUBBY_TUBBZ?select 1 from dual where 1 not in (select col1 from in_or_not);
                 1
                 1
1 row selected.
Elapsed: 00:00:00.00
TUBBY_TUBBZ?insert into in_or_not values (NULL);
1 row created.
Elapsed: 00:00:00.00
TUBBY_TUBBZ?select 1 from dual where 1 not in (select col1 from in_or_not);
no rows selected
Elapsed: 00:00:00.01http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:442029737684

Similar Messages

  • TooManyObjectsException on Select with Where

    i'm using ADF and JSF in Oracle JDeveloper Studio Edition (10.1.3.0.4) with SU5
    the project I'm working on, we need to filter on week numbers and usernames, both represented as a string throughout the application. currently we are doing this by defining those 2 parameters in a JSP page in inputtext fields which are bound to a backing bean.
    when i press a button, a method is triggered that reads those coreInputText fields in that same backing bean and defines the where clause on the necessary view object. this query runs fine (i took it out of the running log and executed in the database web interface) and most of the time it even runs fine within the page as well.
    in fact, it works as long as i leave the filled in filter variables the way they are by default, but when i choose to alter that param it throws a TooManyObjectsException. even tho (as i said) the query runs fine outside the application.
    the method applying the filter is within the automatically bound backing bean connected to the JSP page, calling a pageForward which returns to the page it came from.
    I'm running out of possible causes for this exception. for the keys are fine as far as i can see. the query itself is good. it does work every 1st attempt (calling a vo.clearCache(); has no noticable effect).
    the stack trace below makes me think i somehow found a bug where the entity cache cannot be synchronized, but I'm not experienced enough to tell anything sensible on this part.
    06/11/07 14:35:37 [543] *** DCDataControl.sync() called from :DCBindingContainer.refresh
    06/11/07 14:35:37 [544] valiateToken:Decompressed BC state:BCST:=0%V%=NUrenoverzichtViewIterator=-D-000100000002C109,weekCodesViewIterator=-D-000200000006323030363338000000046261736B,
    06/11/07 14:35:37 [545] OracleSQLBuilder Executing Select on: WEEKCODES (false)
    06/11/07 14:35:37 [546] Reusing prepared FAULT-IN statement
    06/11/07 14:35:37 [547] EntityCache:add ERROR - **new/modified row with same primary key as an existing row**
    06/11/07 14:35:37 [548] DCBindingContainer.reportException :oracle.jbo.TooManyObjectsException
    06/11/07 14:35:37 [549] oracle.jbo.TooManyObjectsException: JBO-25013: Te veel objecten komen overeen met de primaire sleutel oracle.jbo.Key[200637 bask ].
         at oracle.jbo.server.EntityCache.add(EntityCache.java:553)
         at oracle.jbo.server.EntityCache.replace(EntityCache.java:1065)
         at oracle.jbo.server.EntityImpl.setAttributeValueInternal(EntityImpl.java:2445)
         at oracle.jbo.server.EntityImpl.setAttributeValue(EntityImpl.java:2197)
         at oracle.jbo.server.AttributeDefImpl.set(AttributeDefImpl.java:1894)
         at oracle.jbo.server.EntityImpl.setAttributeInternal(EntityImpl.java:1076)
         at model.entity.WeekcodesImpl.setWeekcode(WeekcodesImpl.java:48)
         at model.entity.WeekcodesImpl.setAttrInvokeAccessor(WeekcodesImpl.java:91)
         at oracle.jbo.server.EntityImpl.setAttribute(EntityImpl.java:989)
         at oracle.jbo.server.ViewRowStorage.setAttributeValue(ViewRowStorage.java:1312)
         at oracle.jbo.server.ViewRowStorage.setAttributeInternal(ViewRowStorage.java:1216)
         at oracle.jbo.server.ViewRowImpl.setAttributeInternal(ViewRowImpl.java:1116)
         at oracle.jbo.server.ViewRowImpl.setAttrInvokeAccessor(ViewRowImpl.java:1091)
         at oracle.jbo.server.ViewRowImpl.setAttribute(ViewRowImpl.java:838)
         at oracle.adf.model.binding.DCDataControl.setAttributeInRow(DCDataControl.java:1956)
         at oracle.adf.model.bc4j.DCJboDataControl.setAttributeInRow(DCJboDataControl.java:1774)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.setAttributeInRow(JUCtrlValueBinding.java:645)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.setAttribute(JUCtrlValueBinding.java:913)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.updateTargetFromSelectedValue(JUCtrlListBinding.java:1477)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.setAttributeFromValueList(JUCtrlListBinding.java:1419)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.setSelectedIndex(JUCtrlListBinding.java:720)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.setInputValue(JUCtrlListBinding.java:1830)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.put(JUCtrlValueBinding.java:1803)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.put(JUCtrlListBinding.java:1781)
         at com.sun.faces.el.PropertyResolverImpl.setValue(PropertyResolverImpl.java:158)
         at oracle.adfinternal.view.faces.model.FacesPropertyResolver.setValue(FacesPropertyResolver.java:155)
         at com.sun.faces.el.impl.ArraySuffix.setValue(ArraySuffix.java:192)
         at com.sun.faces.el.impl.ComplexValue.setValue(ComplexValue.java:171)
         at com.sun.faces.el.ValueBindingImpl.setValue(ValueBindingImpl.java:234)
         at oracle.adf.view.faces.component.UIXEditableValue.updateModel(UIXEditableValue.java:323)
         at oracle.adf.view.faces.component.UIXEditableValue.processUpdates(UIXEditableValue.java:284)
         at javax.faces.component.UIForm.processUpdates(UIForm.java:196)
         at oracle.adf.view.faces.component.UIXComponentBase.updateChildrenImpl(UIXComponentBase.java:887)
         at oracle.adf.view.faces.component.UIXComponentBase.updateChildren(UIXComponentBase.java:876)
         at oracle.adf.view.faces.component.UIXComponentBase.processUpdates(UIXComponentBase.java:701)
         at oracle.adf.view.faces.component.UIXComponentBase.updateChildrenImpl(UIXComponentBase.java:887)
         at oracle.adf.view.faces.component.UIXComponentBase.updateChildren(UIXComponentBase.java:876)
         at oracle.adf.view.faces.component.UIXComponentBase.processUpdates(UIXComponentBase.java:701)
         at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:935)
         at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:363)
         at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:81)
         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 com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:367)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:336)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:196)
         at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:332)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:627)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:218)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:119)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:230)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocketAcceptHandler.java:33)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:831)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    06/11/07 14:35:37 [550] * * * BindingContainer caching EXCEPTION:oracle.jbo.TooManyObjectsException
    I hope someone can help out. obviously i tried google, even google codesearch. but either this is a new problem or I'm using the wrong search terms. i hope someone can help out here.
    for starters: thanks for reading this far!
    ps: some error parts are dutch for an unknown reason, yet the error codes and exception names are still universal!

    i'm using ADF and JSF in Oracle JDeveloper Studio Edition (10.1.3.0.4) with SU5
    the project I'm working on, we need to filter on week numbers and usernames, both represented as a string throughout the application. currently we are doing this by defining those 2 parameters in a JSP page in inputtext fields which are bound to a backing bean.
    when i press a button, a method is triggered that reads those coreInputText fields in that same backing bean and defines the where clause on the necessary view object. this query runs fine (i took it out of the running log and executed in the database web interface) and most of the time it even runs fine within the page as well.
    in fact, it works as long as i leave the filled in filter variables the way they are by default, but when i choose to alter that param it throws a TooManyObjectsException. even tho (as i said) the query runs fine outside the application.
    the method applying the filter is within the automatically bound backing bean connected to the JSP page, calling a pageForward which returns to the page it came from.
    I'm running out of possible causes for this exception. for the keys are fine as far as i can see. the query itself is good. it does work every 1st attempt (calling a vo.clearCache(); has no noticable effect).
    the stack trace below makes me think i somehow found a bug where the entity cache cannot be synchronized, but I'm not experienced enough to tell anything sensible on this part.
    06/11/07 14:35:37 [543] *** DCDataControl.sync() called from :DCBindingContainer.refresh
    06/11/07 14:35:37 [544] valiateToken:Decompressed BC state:BCST:=0%V%=NUrenoverzichtViewIterator=-D-000100000002C109,weekCodesViewIterator=-D-000200000006323030363338000000046261736B,
    06/11/07 14:35:37 [545] OracleSQLBuilder Executing Select on: WEEKCODES (false)
    06/11/07 14:35:37 [546] Reusing prepared FAULT-IN statement
    06/11/07 14:35:37 [547] EntityCache:add ERROR - **new/modified row with same primary key as an existing row**
    06/11/07 14:35:37 [548] DCBindingContainer.reportException :oracle.jbo.TooManyObjectsException
    06/11/07 14:35:37 [549] oracle.jbo.TooManyObjectsException: JBO-25013: Te veel objecten komen overeen met de primaire sleutel oracle.jbo.Key[200637 bask ].
         at oracle.jbo.server.EntityCache.add(EntityCache.java:553)
         at oracle.jbo.server.EntityCache.replace(EntityCache.java:1065)
         at oracle.jbo.server.EntityImpl.setAttributeValueInternal(EntityImpl.java:2445)
         at oracle.jbo.server.EntityImpl.setAttributeValue(EntityImpl.java:2197)
         at oracle.jbo.server.AttributeDefImpl.set(AttributeDefImpl.java:1894)
         at oracle.jbo.server.EntityImpl.setAttributeInternal(EntityImpl.java:1076)
         at model.entity.WeekcodesImpl.setWeekcode(WeekcodesImpl.java:48)
         at model.entity.WeekcodesImpl.setAttrInvokeAccessor(WeekcodesImpl.java:91)
         at oracle.jbo.server.EntityImpl.setAttribute(EntityImpl.java:989)
         at oracle.jbo.server.ViewRowStorage.setAttributeValue(ViewRowStorage.java:1312)
         at oracle.jbo.server.ViewRowStorage.setAttributeInternal(ViewRowStorage.java:1216)
         at oracle.jbo.server.ViewRowImpl.setAttributeInternal(ViewRowImpl.java:1116)
         at oracle.jbo.server.ViewRowImpl.setAttrInvokeAccessor(ViewRowImpl.java:1091)
         at oracle.jbo.server.ViewRowImpl.setAttribute(ViewRowImpl.java:838)
         at oracle.adf.model.binding.DCDataControl.setAttributeInRow(DCDataControl.java:1956)
         at oracle.adf.model.bc4j.DCJboDataControl.setAttributeInRow(DCJboDataControl.java:1774)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.setAttributeInRow(JUCtrlValueBinding.java:645)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.setAttribute(JUCtrlValueBinding.java:913)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.updateTargetFromSelectedValue(JUCtrlListBinding.java:1477)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.setAttributeFromValueList(JUCtrlListBinding.java:1419)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.setSelectedIndex(JUCtrlListBinding.java:720)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.setInputValue(JUCtrlListBinding.java:1830)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.put(JUCtrlValueBinding.java:1803)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.put(JUCtrlListBinding.java:1781)
         at com.sun.faces.el.PropertyResolverImpl.setValue(PropertyResolverImpl.java:158)
         at oracle.adfinternal.view.faces.model.FacesPropertyResolver.setValue(FacesPropertyResolver.java:155)
         at com.sun.faces.el.impl.ArraySuffix.setValue(ArraySuffix.java:192)
         at com.sun.faces.el.impl.ComplexValue.setValue(ComplexValue.java:171)
         at com.sun.faces.el.ValueBindingImpl.setValue(ValueBindingImpl.java:234)
         at oracle.adf.view.faces.component.UIXEditableValue.updateModel(UIXEditableValue.java:323)
         at oracle.adf.view.faces.component.UIXEditableValue.processUpdates(UIXEditableValue.java:284)
         at javax.faces.component.UIForm.processUpdates(UIForm.java:196)
         at oracle.adf.view.faces.component.UIXComponentBase.updateChildrenImpl(UIXComponentBase.java:887)
         at oracle.adf.view.faces.component.UIXComponentBase.updateChildren(UIXComponentBase.java:876)
         at oracle.adf.view.faces.component.UIXComponentBase.processUpdates(UIXComponentBase.java:701)
         at oracle.adf.view.faces.component.UIXComponentBase.updateChildrenImpl(UIXComponentBase.java:887)
         at oracle.adf.view.faces.component.UIXComponentBase.updateChildren(UIXComponentBase.java:876)
         at oracle.adf.view.faces.component.UIXComponentBase.processUpdates(UIXComponentBase.java:701)
         at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:935)
         at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:363)
         at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:81)
         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 com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:367)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:336)
         at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:196)
         at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
         at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:332)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:627)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:218)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:119)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:230)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocketAcceptHandler.java:33)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:831)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    06/11/07 14:35:37 [550] * * * BindingContainer caching EXCEPTION:oracle.jbo.TooManyObjectsException
    I hope someone can help out. obviously i tried google, even google codesearch. but either this is a new problem or I'm using the wrong search terms. i hope someone can help out here.
    for starters: thanks for reading this far!
    ps: some error parts are dutch for an unknown reason, yet the error codes and exception names are still universal!

  • JPA - Select with where clause

    Hi
    I have 2 classes:
    -Class A
    -Class B with a member which holds a reference to an object of Class A --> unidirectional one-to-one relation. The mapping is the following:
                   <one-to-one name="a">
                        target-entity="domain.A" fetch="LAZY"
                        optional="false">
                        <join-column name="ID" table="A" />
                   </one-to-one>
    Now i want to find all objects of B which have a certain instance of A. I tried this, but it doesn't work:
         <named-query name="findBsByA">
              <query>select b from B b where b.a = ?1</query>
         </named-query>
    Any suggestions?
    Thanks for help
    Michael

    name or ID might be reserved words in access. Either change the name of the column or put [] around them. Also, you ar looking for a record where fields name and name1 are equal. You probably don't have a name1 field.
    String name1=nameTextfield.getText().trim();
    String query="SELECT [ID] from Suppliers WHERE [name]='"+name1+"';"
    Pay attention to the single and double quotes I have.

  • Select with where condition comparing different domains

    SELECT *
               FROM table
               FOR ALL ENTRIES IN it_temp
               WHERE col1 =  it_temp-col_id.
    col1 is of type char20
    it_temp-col_id is of type char10.
    "col1" and "it_temp-col_id" must have the same type and the same length.
    do someone know a workaround?
    thanks!!

    types : begin of ity_temp_1,
                   col_temp type table-col1, " this is type 20.
                endof ity_temp_1.
    data: lt_temp_1 type standard table of ity_temp_1,
             ls_temp_1 type ity_temp_1.
    loop at it_temp into is_temp.
        clear ls_temp_1.
        ls_temp_1-col_temp =    is_temp-col1. " passing col1(type 10 to col_temp of type 20.)
        append ls_temp_1 into lt_temp_1.
        clear : is_temp.
    endloop.
    "now lt_temp_1 holds matching domain.
    SELECT *
    FROM table
    FOR ALL ENTRIES IN lt_temp_1 " comparing with passed values with same domain
    WHERE col1 = lt_temp_1-col_temp.

  • SELECT with WHERE clause for MSAccess from JDBC

    Hi,
    I am new user of MSAccess.I am getting exception: Invalid user type when i was trying the following code:
    String name1=nameTextfield.getText().trim();
    String query="SELECT ID from Suppliers WHERE name=name1;"
    Statement stmt=con.createStatement();
    ResultSet rs=stmt.executeQuery(query);
    while(rs.next())
    String id1=rs.getInt(1);
    System.out.println(id1);
    nameTextField is JTextField in my GUI.
    ID id auto field in table Suppliers.
    I am using MSAccess 97.
    I came to know that the JDBC SQL queries will be different for Access.
    Any body help me how to write SELECT statement?
    Thanks in advance,
    Sai Ram

    name or ID might be reserved words in access. Either change the name of the column or put [] around them. Also, you ar looking for a record where fields name and name1 are equal. You probably don't have a name1 field.
    String name1=nameTextfield.getText().trim();
    String query="SELECT [ID] from Suppliers WHERE [name]='"+name1+"';"
    Pay attention to the single and double quotes I have.

  • How to tell buttons to select with ENTER (not only buth SPACE)?

    The standard behaviour of the Java Swing components are different than the standard Windows behaviour. In Windows, a button is selected if you press ENTER/Return. In Java Swing, this doesn't work - you have to press SPACE. Is there a general setting in Swing to change this behaviour for all buttons (also in dialogs)?

    Well, i found the basic reason: i use Swing default Look&Feel (Metal). If i use Windows Look&Feel, this button selektion behaviour changes => ENTER in Windows Look&Feel is SPACE in Metal Look&Feel (for button selections).

  • How to create VO with multiple dynamic where clauses on select with UNION?

    I am trying to implement the View Object for the UNION query that looks like this:
         select a,b,c...
              from t1,t2,...
              where dynamic_where_clause1     
         union all
         select a,b,c,...
              from t11,t12, ...
              where dynamic_where_clause2
    There are up to 60 input parameters that are used to generate dynamic where clauses. They are actually created by calling PL SQL function.
    So far, I was not able to assign both where clauses to the view object. Is there a workable solution for this problem, besides resorting to programmatic View Object?
    I understand that recommended way with UNIONs is to wrap both queries into a parent select:
    select * from (
         select a,b,c...
              from t1,t2,...
              where ... -- table relationship joints
         union all
         select a,b,c,...
              from t11,t12, ...
              where ... -- table relationship joints
    ) QRSLT
         where dynamic_where_clause
    Unfortunately this approach doesn't work here, since individual selects are producing unmanageable amount of data and resulting query takes forever to complete.

    I afraid I would not have any real benefits from using VO if I replace the entire query with every request. Actually, the performance may suffer.
    I solved the problem by creating a POJO Data Control and invoking the custom select query from java. Not sure if it is the best approach to the problem, but implementation time is limited and it works.
    Actually, this is not the first time I see the need to implement VO with complicated SQL like select with unions and dynamic pieces. It would be nice to find a solution and not resort to workarounds.
    Edited by: viksicom on Aug 2, 2012 8:48 AM

  • Error  " Selected numbers does not agree with transferred"

    Hi,
    While in production support I got a issue saying
    Error  " Selected numbers does not agree with transferred"
    How to solve this.
    Regards
    San Reddy

    Hi,
    This doesnt mean that its a failure.
    I will suggest you to check a few places where you can see the status
    1) SM37 job log (In source system if load is from R/3 or in BW if its a datamart load) (give request name) and it should give you the details about the request. If its active make sure that the job log is getting updated at frequent intervals.
    Also see if there is any 'sysfail' for any datapacket in SM37.
    2) SM66 get the job details (server name PID etc from SM37) and see in SM66 if the job is running or not. (In source system if load is from R/3 or in BW if its a datamart load). See if its accessing/updating some tables or is not doing anything at all.
    3) RSMO see what is available in details tab. It may be in update rules.
    4) ST22 check if any short dump has occured.(In source system if load is from R/3 or in BW if its a datamart load)
    5) SM58 and BD87 for pending tRFCs.
    Once you identify you can rectify the error.
    If all the records are in PSA you can pull it from the PSA to target. Else you may have to pull it again from source infoprovider.
    If its running and if you are able to see it active in SM66 you can wait for some time to let it finish. You can also try SM50 / SM51 to see what is happening in the system level like reading/inserting tables etc.
    If you feel its active and running you can verify by checking if the number of records has increased in the data tables.
    SM21 - Job log can also be helpful.
    In your case its probably because of tRFC issue.
    Check SM58 / BD87 for pending tRFCs.
    Thanks,
    JituK

  • CONNECT BY with CROSS JOIN and WHERE not executing as described in doc

    Hello all,
    please see these two statements. They are the same, but the 1st uses t1 INNER JOIN t2 while the snd uses a CROSS JOIN with WHERE.
    The 2nd statement shows one row more than the first, but the CROSS JOIN with WHERE is the same as the INNER JOIN.
    The result would be OK if Oracle did:
    JOIN -> CONNECT BY PRIOR -> WHERE
    But according to the docs it does:
    JOIN (and WHEREs for JOINS) -> CONNECT BY PRIOR -> Rest of WHERE
    See http://docs.oracle.com/cd/E11882_01/server.112/e26088/queries003.htm#SQLRF52332 for details. There it says:
    Oracle processes hierarchical queries as follows:
    A join, if present, is evaluated first, whether the join is specified in the FROM clause or with WHERE clause predicates.
    The CONNECT BY condition is evaluated.
    Any remaining WHERE clause predicates are evaluated.
    +.....+
    Is this a bug? I'd say yes, because it differs from the docs and it also is not what people are used to ("a,b WHERE" is the same as "a INNER JOIN b").
    Thanks,
    Blama
    --Statement 1:
    WITH t1
    AS
    (SELECT 1 a, 2 b FROM DUAL UNION ALL
    SELECT 2 a, 3 b FROM DUAL UNION ALL
    SELECT 3 a, 4 b FROM DUAL UNION ALL
    SELECT 4 a, 5 b FROM DUAL UNION ALL
    SELECT 5 a, 6 b FROM DUAL),
    t2 AS
    (SELECT 1 c FROM DUAL UNION ALL
    SELECT 2 c FROM DUAL UNION ALL
    SELECT 3 c FROM DUAL UNION ALL
    SELECT 5 c FROM DUAL)
    SELECT DISTINCT t1.a, t2.c, t1.b, level, SYS_CONNECT_BY_PATH(t1.a, '/') Path
    FROM t1 INNER JOIN t2
    ON t1.a = t2.c
    CONNECT BY t1.a = PRIOR t1.b
    START WITH t1.a = 1
    ORDER BY
    1,2,3;
    --Result:
    --1     1     2     1     /1
    --2     2     3     2     /1/2
    --3     3     4     3     /1/2/3
    --Statement 2:
    WITH t1
    AS
    (SELECT 1 a, 2 b FROM DUAL UNION ALL
    SELECT 2 a, 3 b FROM DUAL UNION ALL
    SELECT 3 a, 4 b FROM DUAL UNION ALL
    SELECT 4 a, 5 b FROM DUAL UNION ALL
    SELECT 5 a, 6 b FROM DUAL),
    t2 AS
    (SELECT 1 c FROM DUAL UNION ALL
    SELECT 2 c FROM DUAL UNION ALL
    SELECT 3 c FROM DUAL UNION ALL
    SELECT 5 c FROM DUAL)
    SELECT DISTINCT t1.a, t2.c, t1.b, level, SYS_CONNECT_BY_PATH(t1.a, '/') Path
    FROM t1 CROSS JOIN t2
    WHERE t1.a = t2.c
    CONNECT BY t1.a = PRIOR t1.b
    START WITH t1.a = 1
    ORDER BY
    1,2,3;
    --Result:
    --1     1     2     1     /1
    --2     2     3     2     /1/2
    --3     3     4     3     /1/2/3
    --5     5     6     5     /1/2/3/4/5My details:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE     11.2.0.2.0     Production
    TNS for Solaris: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production

    blama wrote:
    Hello Paul,
    that means that "a,b" isn't the same as "a CROSS JOIN b".
    I don't think that that is really the case.
    Do you have docs on this one?No explicit docs just (my) logic - having said that, I suppose it is implied that if you are doing ANSI style joins, it's not the where clauses that
    are specifying the join.
    If you do t1,t2 where t1.a=t2.a then Oracle figures out the kind of join from the (relevant) where clauses and treats the other where clauses after the CONNECT BY.
    If you do t1 cross join t2 where t1.a=t2.a then you are saying the join is completely specified by the CROSS JOIN - i.e it's Cartesian. Oracle doesn't look at the where clauses for this. Therefore
    all where clauses are treated as 'other' and are evaluated after the CONNECT BY.
    So, in my mind it's 10g that has the bug.

  • HOW TO SELECT ONLY THOSE RECORDS WHERE NOT AVAILABLE ON SECOND TABLE

    hi
    i have two tables one name is menus and second name is UGroupDetail. Actually i have created it for user role privileges for my application
    USE [LedgerDB]
    GO
    /****** Object: Table [dbo].[Menus] Script Date: 03/28/2015 13:45:27 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Menus](
    [RightID] [int] NOT NULL,
    [RightName] [nvarchar](200) NULL,
    [GroupID] [int] NULL,
    CONSTRAINT [PK_Menus] PRIMARY KEY CLUSTERED
    [RightID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    second table is
    USE [LedgerDB]
    GO
    /****** Object: Table [dbo].[UGroupDetail] Script Date: 03/28/2015 13:46:12 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[UGroupDetail](
    [RightID] [int] NOT NULL,
    [RightName] [nvarchar](200) NULL,
    [GroupID] [int] NULL
    ) ON [PRIMARY]
    GO
    ALTER TABLE [dbo].[UGroupDetail] WITH CHECK ADD CONSTRAINT [FK_UGroupDetail_Menus] FOREIGN KEY([RightID])
    REFERENCES [dbo].[Menus] ([RightID])
    ON UPDATE CASCADE
    ON DELETE CASCADE
    GO
    ALTER TABLE [dbo].[UGroupDetail] CHECK CONSTRAINT [FK_UGroupDetail_Menus]
    GO
    ALTER TABLE [dbo].[UGroupDetail] WITH CHECK ADD CONSTRAINT [FK_UGroupDetail_UserGroup] FOREIGN KEY([GroupID])
    REFERENCES [dbo].[UserGroup] ([GroupID])
    ON UPDATE CASCADE
    ON DELETE CASCADE
    GO
    ALTER TABLE [dbo].[UGroupDetail] CHECK CONSTRAINT [FK_UGroupDetail_UserGroup]
    UGroupDetail have many groups as assigned to a new user but Menus table has only default groups which is 90 records
    Menus table is a primary table and UGroupDetail is a Foreign key table
    now i want to combined these tables and want to get only remaining records for each group
    for example i have assigned 5 roles to GroupID 2 and now when i apply select commands the result should be 85 out 90 for GroupID 2
    but i have not idea how to modify select query for get desired result

    I don't really understand the tables. What is GroupID doing in the Menues table? And what does an entry without a RightName mean? Shouldn't that column be NOT NULL?
    The UGroupDetail does not have any primary key. From your description, I would expect the PK to be (RightID, GroupID). But strangely enough, GroupID is nullable. So is RightName, but I think this column is redundant and should be removed.
    Anyway, if I understand your question correctly, you need something like:
    SELECT UG.Name, M.RightName
    FROM   UserGroups UG
    CROSS  JOIN Menus M
    WHERE  NOT EXISTS (SELECT *
                       FROM   UGroupDetail UGD
                       WHERE  UG.GroupID = UGD.GroupID
                         AND  UG.RightID = M.RightID)
    Erland Sommarskog, SQL Server MVP, [email protected]

  • I created an application and in  that application if date is changed the application starts from splash screen on re-entering and if date is not changed and u re-enters the application then it open in page where u leaved.It works with iPod not with iPhone

    I created an application and in  that application if date is changed the application starts from splash screen on re-entering and if date is not changed and u re-enters the application then it open in page where u leaved.It works with iPod not with iPhone

    Try posting in the developer forums to see if you can get some assistance,you'll have to be a registered developer for access though.
    developer.apple.com

  • Select clause with where part is needs 600 times longer to complete

    Hello.
    I have two select clauses one with where, which needs 120 seconds to complete and one without where, which completes in 0,3 seconds. I want to know why is that.
    120 seconds
    SELECT B.* FROM
    (SELECT A.OLOG, MCL_ISPROTOCOLALLOWED('LMOD', 'MCLI', A.OPRG) ALLOWED FROM  (SELECT DISTINCT OLOG, OPRG FROM FLOG WHERE FIRM = '001') A) B WHERE B.ALLOWED = '1' ORDER BY OLOG;0,3 seconds
    SELECT B.* FROM
    (SELECT A.OLOG, MCL_ISPROTOCOLALLOWED('LMOD', 'MCLI', A.OPRG) ALLOWED FROM  (SELECT DISTINCT OLOG, OPRG FROM FLOG WHERE FIRM = '001') A) B ORDER BY OLOG;Table FLOG has arround 270000 records, but only 40 of them are distinct.
    IsProtocolAllowed checks if user has a permision to view the record.
    Thank you for your help.
    Regards,
    Borut Ojcinger
    Edited by: 993896 on 14.3.2013 7:24

    Hi,
    welcome to the forum.
    Please read SQL and PL/SQL FAQ
    If you have a performance issue have a look at SQL and PL/SQL FAQ
    Additionally when you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Wrong query is getting generated in WHERE NOT EXISTS  with group by clause

    Query is getting generated wrongly in where not exists section when i use group by function.Please prvoide me any clue to over come the problem.
    /* DETECTION_STRATEGY = NOT_EXISTS */
    INSERT /*+ APPEND */ INTO STG_ETL.I$_DCMT_TIMEZONE_LOOKUP
         TZ_OFFSET,
         ADT_CRT_DT,
         ADT_UPDT_DT,
         IND_UPDATE
    SELECT * FROM (
    SELECT      
         to_number(KOFAX.RECEIVED_TZ)     TZ_OFFSET,
         min(sysdate)     ADT_CRT_DT,
         min(sysdate)     ADT_UPDT_DT,
         'I' IND_UPDATE
    FROM     ESTG.FLAT_FIL_DMS_KOFAX KOFAX
    WHERE     (1=1)
    And (KOFAX.LD_DT = ( select MAX(LD_DT) from ESTG.FLAT_FIL_DMS_KOFAX INNER
    where INNER.ENGAGEMENT=KOFAX.ENGAGEMENT
                   and INNER.KOFAX_FILE_NM = KOFAX.KOFAX_FILE_NM
                   AND INNER.IM_CUST_ID = KOFAX.IM_CUST_ID
              and INNER.BATCH_ID=KOFAX.BATCH_ID)
    AND
    (TO_DATE(KOFAX.LD_DT)>=TO_DATE(SUBSTR('#WAREHOUSE.P_EDW_LAST_RUN',1,10),'YYYY-MM-DD'))
    And (substr(KOFAX.RECEIVED_TZ,1,1) <> '+')
    Group By to_number(KOFAX.RECEIVED_TZ)
    ) S
    WHERE NOT EXISTS (
         SELECT     'X'
         FROM     EDW.DCMT_TIMEZONE_LOOKUP T
         WHERE     T.TZ_OFFSET     = S.TZ_OFFSET AND
         )

    Easiest fix for you would be to change the detection_strategy on the IKM from NOT_EXISTS to either :
    MINUS
    -- Try this out, it should work, it will give the same data through the equiverlant steps.
    NONE
    -- This will load all incoming data into your I$ table, there will be more rows to crunch in the following 'Flag Rows for Update' step, it might give incorrect results potentially - you will have to test it.
    So try MINUS first, failing that, see if NONE gives you what you want in your target.
    Are you inserting only new data or updating existing data?

  • How do I fix Mountain Lion issue after login where Keychain Access attempts to open, hanging up with "application not responding" message?

    How do I fix Mountain Lion issue after login where Keychain Access attempts to open, hanging up with "application not responding" message?

    You could try booting into Safe Mode to see if that will help. And "Repair Permissions" in Disk Utility.
    Have you got Keychain set to open on Login or is it attempting to open on it's own.

  • BW:  Data Packages Selected number does not agree with transferred

    Hi,
    I am running into an issue with an existing master data text load process chain in Production.  The extractor is from ERP and there are only 159 records.  What is happening is the chain is stuck on yellow but there is an issue with the data packages.  The status error message is 'Missing data packages for PSA table'.  Clicking into the Details tab the message then states Data Package 1:  arrived in BW; Processing:  Selected number does not agree with transferred.
    The version is BI 7.0.  I have done the following steps and still no luck.  Looking for any suggestions.  Thanks.
    ERP
        SM37 (Job always finishes)
        SM58 (No IDOCS stuck)
        ST22 (No short dumps)
    BW
        SM58 (No IDOCS stuck)
        SM37 (Job always finishes)
        ST22 (No short dumps)
    Reactivated Datasource:  RSDS_DATASOURCE_ACTIVATE_ALL
    Reactivated Transformation:  RSDG_TRFN_ACTIVATE

    Hi
    Just check whether source system connection is ok in RSA1.
    if it is fine then have a loo at the below thread(last post)
    Data Load from R/3 to BW-'Selected number does not agree with transferred'
    Regards,
    Venkatesh

Maybe you are looking for