EQUAL condition on WHERE clause not working

Hi,
Can someone please tell me why the following WHERE clause  (marked with ***** below) is not finding any EQUAL conditions?
I know that table i_cust_mast is populated with several thousand rows and that there ARE matching rows in KNVP.
Here is the code as I have it:
TYPES:
      BEGIN OF t_cust_mast,
        kunnr TYPE kunnr,
        name1 TYPE name1_gp,
        name2 TYPE name2_gp,
        stras TYPE stras_gp,
        adrnr TYPE adrnr,
        ort01 TYPE ort01_gp,
        regio TYPE regio,
        pstlz TYPE pstlz,
        vkbur TYPE vkbur,
        konda TYPE konda,
        sortl TYPE sortl,
        katr1 TYPE katr1,
        katr2 TYPE katr2,
        katr3 TYPE katr3,
        katr4 TYPE katr4,
        katr5 TYPE katr5,
        katr6 TYPE katr6,
        katr7 TYPE katr7,
        katr8 TYPE katr8,
        katr9 TYPE katr9,
        katr10 TYPE katr10,
        bzirk TYPE bzirk,
        vkgrp TYPE vkgrp,
        kdgrp TYPE kdgrp,
        klabc TYPE klabc,
        kondaa TYPE konda,
        kalks TYPE kalks,
        pltyp TYPE pltyp,
        hityp TYPE hityp_kh,
        hkunnr TYPE hkunnr_kh,
        datab TYPE datab,
        datbi TYPE datbi,
        lzone TYPE lzone,
      parvw TYPE parvw,
        kunn2 TYPE kunn2,
        kunn2a TYPE kunn2,
        kunn2b TYPE kunn2,
        kunn2c TYPE kunn2,
        kunn2d TYPE kunn2,
        kunn2e TYPE kunn2,
        kunn2f TYPE kunn2,
        kunn2g TYPE kunn2,
        parza TYPE parza,
        ktokd TYPE ktokd,
        loevm TYPE loevm_x,
      END OF t_cust_mast .
    TYPES:
      BEGIN OF t_part_func,
        kunnr TYPE kunnr,
        parvw type parvw,
        kunn2 TYPE kunn2,
        parza type parza,
      END OF t_part_func .
    TYPES:
      t_t_cust_mast TYPE STANDARD TABLE OF t_cust_mast,
      t_t_part_func TYPE STANDARD TABLE OF t_part_func.
    DATA: i_cust_mast TYPE t_t_cust_mast,
          i_part_func TYPE t_t_part_func.
  CONSTANTS: c_type_a TYPE msgty VALUE 'A'.
  FIELD-SYMBOLS: <x_cm> LIKE LINE OF i_cust_mast.
Get Customer Master Data
  SELECT
   hkunnr hname1 hname2 hstras hadrnr hort01 h~regio
   hpstlz ivkbur ikonda hsortl hkatr1 hkatr2 h~katr3
   hkatr4 hkatr5 hkatr6 hkatr7 hkatr8 hkatr9 h~katr10
   ibzirk ivkgrp ikdgrp iklabc ikonda ikalks i~pltyp
   khityp khkunnr kdatab kdatbi h~lzone
   hktokd hloevm
  INTO TABLE i_cust_mast " up to 50 rows
  FROM kna1 AS h
  JOIN knvv AS i ON ikunnr = hkunnr
  JOIN knvh AS k ON hityp = c_type_a   " 'A'
                AND kkunnr = ikunnr
                AND kvkorg = ivkorg
                AND kvtweg = ivtweg
                AND kspart = ispart
                AND k~datab <= sy-datum
                AND k~datbi >= sy-datum.
  IF sy-subrc = 0.
    SORT i_cust_mast[] BY kunnr.
  ENDIF.
Get Partner Function Data for each Customer Master Record
  LOOP AT i_cust_mast ASSIGNING <x_cm>.
    SELECT hkunnr hparvw hkunn2 hparza
      INTO TABLE i_part_func
    FROM knvp AS h
      WHERE h~kunnr = <x_cm>-kunnr.        ***** WHERE clause not finding any matches *****
  ENDLOOP.
Thanks!!!
Andy

TYPES:
      BEGIN OF t_cust_mast,
        kunnr TYPE kunnr,
        name1 TYPE name1_gp,
        name2 TYPE name2_gp,
        stras TYPE stras_gp,
        adrnr TYPE adrnr,
        ort01 TYPE ort01_gp,
        regio TYPE regio,
        pstlz TYPE pstlz,
        vkbur TYPE vkbur,
        konda TYPE konda,
        sortl TYPE sortl,
        katr1 TYPE katr1,
        katr2 TYPE katr2,
        katr3 TYPE katr3,
        katr4 TYPE katr4,
        katr5 TYPE katr5,
        katr6 TYPE katr6,
        katr7 TYPE katr7,
        katr8 TYPE katr8,
        katr9 TYPE katr9,
        katr10 TYPE katr10,
        bzirk TYPE bzirk,
        vkgrp TYPE vkgrp,
        kdgrp TYPE kdgrp,
        klabc TYPE klabc,
        kondaa TYPE konda,
        kalks TYPE kalks,
        pltyp TYPE pltyp,
        hityp TYPE hityp_kh,
        hkunnr TYPE hkunnr_kh,
        datab TYPE datab,
        datbi TYPE datbi,
        lzone TYPE lzone,
      parvw TYPE parvw,
        kunn2 TYPE kunn2,
        kunn2a TYPE kunn2,
        kunn2b TYPE kunn2,
        kunn2c TYPE kunn2,
        kunn2d TYPE kunn2,
        kunn2e TYPE kunn2,
        kunn2f TYPE kunn2,
        kunn2g TYPE kunn2,
        parza TYPE parza,
        ktokd TYPE ktokd,
        loevm TYPE loevm_x,
      END OF t_cust_mast .
    TYPES:
      BEGIN OF t_part_func,
        kunnr TYPE kunnr,
        parvw type parvw,
        kunn2 TYPE kunn2,
        parza type parza,
      END OF t_part_func .
    TYPES:
      t_t_cust_mast TYPE STANDARD TABLE OF t_cust_mast,
      t_t_part_func TYPE STANDARD TABLE OF t_part_func.
    DATA: i_cust_mast TYPE t_t_cust_mast,
          i_part_func TYPE t_t_part_func. 
CONSTANTS: c_type_a TYPE msgty VALUE 'A'.
  FIELD-SYMBOLS: <x_cm> LIKE LINE OF i_cust_mast.
Get Customer Master Data
  SELECT
   hkunnr hname1 hname2 hstras hadrnr hort01 h~regio
   hpstlz ivkbur ikonda hsortl hkatr1 hkatr2 h~katr3
   hkatr4 hkatr5 hkatr6 hkatr7 hkatr8 hkatr9 h~katr10
   ibzirk ivkgrp ikdgrp iklabc ikonda ikalks i~pltyp
   khityp khkunnr kdatab kdatbi h~lzone
   hktokd hloevm
  INTO TABLE i_cust_mast " up to 50 rows
  FROM kna1 AS h
  JOIN knvv AS i ON ikunnr = hkunnr
  JOIN knvh AS k ON hityp = c_type_a   " 'A'
                AND kkunnr = ikunnr
                AND kvkorg = ivkorg
                AND kvtweg = ivtweg
                AND kspart = ispart
                AND k~datab <= sy-datum
                AND k~datbi >= sy-datum.
  IF sy-subrc = 0.
    SORT i_cust_mast[] BY kunnr.
  ENDIF.
Get Partner Function Data for each Customer Master Record
  LOOP AT i_cust_mast ASSIGNING <x_cm>.
    SELECT hkunnr hparvw hkunn2 hparza
      INTO TABLE i_part_func
    FROM knvp AS h
      WHERE h~kunnr = <x_cm>-kunnr.
  ENDLOOP.

Similar Messages

  • NVL in where clause not working with UNIX parameters

    Apparently this in a where clause does not work in UNIX scripts...
    .... and trans_date between to_date('&1','YYYY/MM/DD HH24:MI:SS')
    and to_date(NVL('&2','31-DEC-4712'),'YYYY/MM/DD HH24:MI:SS')
    and to_date(NVL('','31-DEC-4712'),'YYYY/MM/DD HH24:MI:SS')
    ERROR at line 14:
    ORA-01858: a non-numeric character was found where a numeric was expected
    How do I get around a null in UNIX? This works fine if both parameters are populated. Thanks.

    Jason ORCL wrote:
    Apparently this in a where clause does not work in UNIX scripts...
    .... and trans_date between to_date('&1','YYYY/MM/DD HH24:MI:SS')
    and to_date(NVL('&2','31-DEC-4712'),'YYYY/MM/DD HH24:MI:SS')
    and to_date(NVL('','31-DEC-4712'),'YYYY/MM/DD HH24:MI:SS')
    ERROR at line 14:
    ORA-01858: a non-numeric character was found where a numeric was expected
    How do I get around a null in UNIX? This works fine if both parameters are populated. Thanks.it's nothing to do with unix at all - your date value doesn't match the format mask that you've entered:
    '31-DEC-4712' doesn't map to 'YYYY/MM/DD HH24:MI:SS' in any universe unfortunately.

  • Query, where clause not working.

    Hi,
    Query is:
    select vbeln posnr matnr
    from vbap
    into table it_ivbap.
    it_ivbap is internal table. i got records when i executed this query.
    gave  a where clause
    select vbeln posnr matnr
    from vbap
    into table it_ivbap
    where vbeln = '5049'.
    it is not returning any records. i tried with all the possile values of vbeln
    what I am doing wrong.
    Thanks in advance.

    Hello,
    Change like this,
    select vbeln posnr matnr
    from vbap
    into table it_ivbap
    where vbeln = '0000005049'. " Check here
    Regards,
    vasanth

  • Two where clauses not working together

    Good afternoon,
    I have a query where I want to find out all unsorted stock (AA, BA, UP & BS) in certain depot's (Carbide dept, Harryworks and Adwick) 
    When I run these where clauses seperately they work but when I combine them they don't work where am I going wrong?
    SELECT tblGRNItem.GRNPrefix + Convert(Varchar(10),tblGRNItem.GRN) AS GRNNumber, tblGRNItemStatus.ShortDescription, tblStorageLocation.Location, tblGRNItem.GRNItemNo, tblSupplier.SupplierName, tblGRNItem.MaterialDescription,tblGRNItem.NettWeight, tblGRNItem.LocalPrice, tblStaff.Initials, tblGRNItem.EstProductionHoursPerPO FROM tblGRNItem INNER JOIN tblGRNItemStatus ON tblGRNItem.GRNItemStatusID = tblGRNItemStatus.ItemStatusID INNER JOIN tblStorageLocation ON tblGRNItem.StorageLocationID = tblStorageLocation.LocationID INNER JOIN tblGRN ON tblGRNItem.GRNID = tblGRN.GRNID INNER JOIN tblSupplier ON tblGRN.SupplierID = tblSupplier.SupplierID INNER JOIN tblStaff ON tblGRNItem.SorterID = tblStaff.UserID
    WHERE tblGRNItemStatus.ShortDescription LIKE 'UP' OR
    tblGRNItemStatus.ShortDescription LIKE 'BA' OR
    tblGRNItemStatus.ShortDescription LIKE 'AA' OR
    tblGRNItemStatus.ShortDescription LIKE 'BS'

    I don't understand the terminology you are using.  Examples would help.
    What do you mean by "works?"  What does the query do that "doesn't work" and what does "works" mean?  "Works" can mean anything from it includes too many rows or it excludes rows.
    Give an example of running the where clause separately (and what is the result you get, either with actual results, representative results or describe the results); give an example of running with the where clauses combined (what is the result ...).
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Programmatic setting of where clause not working.

    Hi,
    I am using Jdeveloper 11.1.2.2 .
    I am trying query some rows from the VO by setting the VO in the programmatic way as given in this documentation : http://docs.oracle.com/cd/E15523_01/web.1111/b31974/bcquerying.htm#CHDEBEAF
    But it is returning no rows. While I tried to query through the SQL Command Line it is querying the rows.
    Is there any conditions that only bind variables declared in the VO can be queried in the programmatic way ? I tried that also. It is still not returning any rows.
    Thanks,
    Nigel.

    in the line of fire wrote:
    The best way to understand sql related issues is to enable debugger logs, where you can see actually what query is then executing. It really helps. Try it.I tried to run in the debugger mode, but there is no query execution seen. It is not throwing any errors, just its not returning the rows in the database.

  • Problem in case of or condition in  where clause in case of leftouter joi.

    hi
    i am encountering a wierd problem.
    in a select query if i have a left outer join and a or condition in where clause the order of condition in or matters and if i use a to_char problem is solved.
    see query below
    select * from custsupp left outer join Salesperson s on custsupp.sales_rep = s.id ,state a where (CS_FLAG='C' or CS_flag ='B') and custsupp.state = a.id
    i have a single record in table custsupp with CS_FLAG ='B' the above does not return result. but if i move CS_FLAG='B' on left of or i.e
    select * from custsupp left outer join Salesperson s on custsupp.sales_rep = s.id ,state a where (CS_FLAG='B' or CS_flag ='C') and custsupp.state = a.id
    i get the rsult.
    also if i remove left outer join and keep order of condition as it is i get result i.e
    select * from custsupp ,state a where (CS_FLAG='C' or CS_flag ='B') and custsupp.state = a.id
    also if i add a to_char to co,umns CS_FLAG i get the result.
    select * from custsupp left outer join Salesperson s on custsupp.sales_rep = s.id ,state a where (to_char(CS_FLAG)='C' or to_char(CS_flag ='B')) and custsupp.state = a.id
    why it is so?
    CS_flag is of type nchar
    Shreyas
    Edited by: shreyasd on Jun 9, 2010 11:07 PM

    First if you don't want to take credit of the free sample then follow the below procedure:
    1. Do the GRN for all the three item and for the free item in the excise tab at the item level select the material as non cenvatable. Just remember to add base value of the item
    2.  If you want to capture the Part1 entry then just do the normal transaction and while posting the excise with J1IEX just remove the excise duties for the free item.
    3. For paying the vendor the excise amount, just do subsequent debit in the MIRO and in the details tab add in the unplanned delivery cost the amount that you want to pay for the excise duties
    Second case if you want to take credit of the duties:
    1. Do the Normal GRN process, add the base value and excise values for the free item.
    2. Post the Excise duites with J1iEX.
    3. The with the account entry you can settle the excise payment
    Hope this will help you
    Enjoyyyyyyyyyyy
    Akshit

  • Problem in adding one condition in where clause

    Hi,
    I am populating this internal table t_bkpf for all entries in gt_covp_ext
      select bukrs belnr gjahr
             bldat budat cpudt
             xblnr waers awtyp awkey
             from bkpf
             into corresponding fields of table t_bkpf
             for all entries in gt_covp_ext
             where bukrs eq gt_covp_ext-bukrs and
                   awtyp eq 'MKPF'.
    Here i have to add one more condition in where clause
    AWKEY = ( Concatenated string of gt_covp_ext-REFBN + gt_covp_ext-REFGJ )
    As i am not using loop at gt_covp_ext.How to implement this condition in Where clause.
    Please help.If you did not understood the requirement reply this post.
    Mukesh Kumar
    Message was edited by:
            mukesh kumar

    Hi,
    Create a new internal table gt_covp_ext_new with the same structure as gt_covp_ext. Include an extra field in gt_covp_ext_new-concat,  to store the concatenated value.
    Copy all entries from gt_covp_ext to gt_covp_ext_new.
    Loop at gt_covp_ext.
    move-corresponding gt_covp_ext to gt_covp_ext_new.
    gt_covp_ext_new-concat = gt_covp_ext-REFBN + gt_covp_ext-REFGJ .
    append gt_covp_ext_new.
    endloop.
    Now use this new internal table in the query.
    select bukrs belnr gjahr
    bldat budat cpudt
    xblnr waers awtyp awkey
    from bkpf
    into corresponding fields of table t_bkpf
    for all entries in gt_covp_ext_new
    where bukrs eq gt_covp_ext_new-bukrs and
    awkey eq  gt_covp_ext_new-concat and
    awtyp eq 'MKPF'.
    Hope this answers your qn.
    Regards,
    Divya

  • How can I pass multiple condition in where clause with the join table?

    Hi:
    I need to collect several inputs at run time, and query the record according to the input.
    How can I pass multiple conditions in where clause with the join table?
    Thanks in advance for any help.
    Regards,
    TD

    If you are using SQL-Plus or Reports you can use lexical parameters like:
    SELECT * FROM emp &condition;
    When you run the query it will ask for value of condition and you can enter what every you want. Here is a really fun query:
    SELECT &columns FROM &tables &condition;
    But if you are using Forms. Then you have to change the condition by SET_BLOCK_PROPERTY.
    Best of luck!

  • How to use the MAX DATE condition in WHERE CLAUSE FILEDS

    Hi,
    I am trying to fetch the result for getting maximun date but when i try to execute the query i am getting the error as follows.
    CONDITION : trunc(max(RD.DATERECEIVED)) BETWEEN TO_DATE('01/08/2011','DD/MM/YYYY') AND TO_DATE('01/08/2011','DD/MM/YYYY')
    ERROR: Group function is not allowed here.
    CHEERS,
    PRABU AMMAIAPPAN

    I see a couple of problems here.
    First, what you posted below is not a syntactically valid query. It seems to be part of a larger query, specifically, this looks to be only the GROUP BY clause of a query.
    Prabu ammaiappan wrote:
    Hi,
    I Have a group function in the Query. Below is the Query i have used it,
    GROUP BY S.FREIGHTCLASS,
    R.CONTAINERKEY,
    S.SKU,
    S.DESCR ||S.DESCRIPTION2,
    S.PVTYPE,
    RD.LOTTABLE06,
    R.WAREHOUSEREFERENCE,
    RD.TOLOC,
    R.ADDWHO,
    R.TYPE,
    S.CWFLAG,
    S.STDNETWGT,
    S.ORDERUOM,
    R.ADDDATE,
    C.DESCRIPTION,
    (CASE WHEN P.POKEY LIKE '%PUR%' THEN 'NULL' ELSE to_char(P.PODATE,'dd/mm/yyyy') END),
    NVL((CASE WHEN R.ADDWHO='BOOMI' THEN RDD.SUPPLIERNAME END),SS.COMPANY),
    RDD.BRAND,
    S.NAPA,
    RD.RECEIPTKEY,
    R.SUSR4,
    P.POKEY,
    RDD.SUSR1,
    r.STATUS, DECODE(RDD.SUSR2,' ',0,'',0,RDD.SUSR2),
    rd.SUSR3Second, the answer to your primary question, "How do I add a predicate with with a MAX() function to my where clause?" is that you don't. As you discovered, if you attempt to do so, you'll find it doesn't work. If you stop and think about how SQL is processed, it should make sense to you why the SQL is not valid.
    If you want to apply a filter condition such as:
    trunc(max(RD.DATERECEIVED)) BETWEEN TO_DATE('01/08/2011','DD/MM/YYYY') AND TO_DATE('01/08/2011','DD/MM/YYYY')you should do it in a HAVING clause, not a where clause:
    select ....
      from ....
    where ....
    group by ....
    having max(some_date) between this_date and that_date;Hope that helps,
    -Mark

  • VOWizard-Bug: WHERE Clause not modified on EO add if manually changed befor

    VOWizard-Bug: WHERE Clause is not modified on adding a EO (with association) if it was manually changed before
    Testcase:
    - Create a VO based on 2 EO (Association already defined) --> Jon in WHERE Clause automatically created by Wizard
    - Then modify the WHERE clause, e.g. change an equal to outer join.
    - All works fine.
    - Then add a EO (also Association defined) and chose some attributes.
    - Test and wonder why there are much more rows in the result than expected.
    - Look into the Query-Tab and control the WHERE clause: Wizard forgot to add the new join... and therefore we get a cartesian product between the old view and the new added EO...
    Possible solutions to fix the Bug:
    1. add the JOIN ;-)
    or
    2. at least display a warning that the JOIN is not automatically created!
    Regards, Markus
    GE Medical Systems

    Hi Markus-
    Once the where clause has been customized, we don't update it in the interest of not messing up the user's custom code. However, we should probably warn the user in the types of cases you mention above that he will need to update the where clause manually to include the new information. We will add this in a future release.
    Thanks,
    Ray

  • Order by clause not working

    Hi, everyone,
    I am trying to use the following insert statement to insert records in asc order. if i use the select statement alone the order by clause works fine, but when i use the same sql and add a insert into table statment the order by clause does not work. I am not getting the records in ascending order. could anybody help me in this regard?
    INSERT INTO cat_sales_stg
    select      b.SSC,                
         ltrim(rtrim(a.CAT_DESC)) cat_desc,                
         SUM(a.AMOUNT) AMOUNT               
    FROM Trans a, SSC b                     
    WHERE a.ACCOUNT_NUMBER = TO_CHAR(b.ACCOUNT_NUMBER)                    
         AND a.TMONTH >= 200905 AND a.TMONTH <= 200910                
         AND a.FORMAT_NAME = 'ABC'                
         AND b.BMONTH = 200910                
         AND b.SAMPLE = 3                
         AND b.BANNER_NAME = 'ABC'               
         AND b.MODEL_NAME = 'XYZ'               
    group by b.SSC, ltrim(rtrim(a.CAT_DESC))
    order by ssc,cat_desc
    Thanks in advance

    user10636796 wrote:
    Hi, everyone,
    I am trying to use the following insert statement to insert records in asc orderWhat Toon, William, and others have said is that you DON'T insert rows in a specific order. That is completely outside the way relational databases are designed. You insert rows as unordered and use an ORDER BY clause in a SELECT when reading them. ORDER BY is for SELECT statements, not INSERT.
    In particular Toon poined out that we can't control where individual rows get stored.
    There is a databas object called a varray that can store data in sorted order. I have never seen them used because selecting the data back out again is more work; using an ordinary table and an ORDER BY clause is much easier.

  • Queryeditor using fields more than once in where clause not possible?

    I have to create a select query with a WHERE clause using a field multiple times.
    I can't get this to work. For example:
    SELECT ALL
      EMSDTALIB.EMSPPA.PAIDNR,
      EMSDTALIB.EMSPPA.PANAAM,
      EMSDTALIB.EMSPPA.PAVLTR,
      EMSDTALIB.EMSPPA.PATITL,
      EMSDTALIB.EMSPPA.PAADRS,
      EMSDTALIB.EMSPPA.PAHSNR,
      EMSDTALIB.EMSPPA.PAHSNT,
      EMSDTALIB.EMSPPA.PAPCA1
    FROM EMSDTALIB.EMSPPA
    WHERE EMSDTALIB.EMSPPA.PABEDR=1 AND EMSDTALIB.EMSPPA.PADTUD=0 AND
      (EMSDTALIB.EMSPPA.PADVBD='001' OR EMSDTALIB.EMSPPA.PADVBD='003' OR EMSDTALIB.EMSPPA.PADVBD='006')How do I get this to work?
    Regards,
    Roland

    Hi Roland, Luca, ICON_SS,
    I just tried similar queries using the latest release bits and it works fine.
    My Queries that worked fine are :
    SELECT ALL DASUSR1.PERSON.PERSONID, DASUSR1.PERSON.NAME, DASUSR1.PERSON.JOBTITLE, DASUSR1.PERSON.FREQUENTFLYER
    FROM DASUSR1.PERSON
    WHERE ( DASUSR1.PERSON.NAME='Able, Tony' OR NAME='Black, John' )
    SELECT ALL DASUSR1.PERSON.PERSONID, DASUSR1.PERSON.NAME, DASUSR1.PERSON.JOBTITLE, DASUSR1.PERSON.FREQUENTFLYER
    FROM DASUSR1.PERSON
    WHERE ( DASUSR1.PERSON.PERSONID=1 OR PERSONID=2 OR PERSONID=3)
    I would suggest you to Download & Install latest Creator bits released 9/27/2004, if not already done.
    Appreciate your valuable feedback,
    Sakthi

  • How to change operator of join conditions in where clause?

    Hello
    I have a situation... I want to change the operator between each join conditions in the where clause when these join conditions are not from the same join..
    For example, I have the following schema:
    Dim1 ------ DimA -------Fact1
    Dim1-------DimB -----Fact1
    So DimA and DimB are aliasas of one dim table, but the join is different.
    Now if I run this model, what I will get in the where clause of the query is:
    Where Dim1 = DimA and Dim1 = DimB and DimA= Fact1 and DimB = fact1.
    Is there a way I can change these "and" operator to "OR", so that the where clause would look like this: Where Dim1 = DimA and Dim1 = DimB and DimA= Fact1 OR DimB = fact1?
    This is different from simply changing the join operator within the same join, because these are different joins and I'd like to control how they relate to each other..
    Please help
    Thanks

    Sometimes, business rules are complex, so there isn't always a way to simplify things.  Is your issue that it's complex and error prone, or is it performance due to the OR clauses?
    One possibility that will at least make it easier to test and debug is something like this:  (pseudocode)
    From Table1 Inner join Table2 on x=y etc.etc.
    CROSS APPLY
    (Select case when a=b and (c=d or e=f) then 1 else 0 end) as Situation1
    , case when h=i or j = k then 1 else 0 end) as situation2
    , case when l = m then 1 else 0 end) as situation 3
    ) as CA_Logic_Simplifier
    Where situation1 = 1 and situation2 = 1 and situation3 = 1
    Although you could say, "Hey, this is basically doing the same thing as before", this approach would be far easier to test and debug, because you can at a glance look at the values for situation1, 2, 3, etc. to see where errors are being introduced. 
    The cross apply makes the columns situation1/2/3 "instantiated", so they are usable in the where clause. Divide and conquer.  

  • In clause not working

    Hi All,
    SELECT sno,mid,mname
    FROM manage_date
    WHERE mname IN
    ('KIRAN-KUMAR',
    'RAHUL-RAJ',
    'KAUSHAL-SONI');
    IF I use this query directly in DB it's working fine.
    But when this query is calling in .net using parameter as below
    it's not giving any records for more than one value.
    IN (:p_mname)
    If I pass one name 'KIRAN-KUMAR' from .net It's working.
    If I pass multiple names from .net query not returning any records.
    Please help me how to resolve this.
    Thanks.

    976208 wrote:
    Hi All,
    SELECT sno,mid,mname
    FROM manage_date
    WHERE mname IN
    ('KIRAN-KUMAR',
    'RAHUL-RAJ',
    'KAUSHAL-SONI');
    IF I use this query directly in DB it's working fine.
    But when this query is calling in .net using parameter as below
    it's not giving any records for more than one value.
    IN (:p_mname)
    If I pass one name 'KIRAN-KUMAR' from .net It's working.
    If I pass multiple names from .net query not returning any records.
    Please help me how to resolve this.
    Thanks.
    But you won't be passing multiple names in that single bind variable, you'll be passing one string of names.  Oracle is not going to magically know that just because you have commas in the string you intend to have seperate values... it doesn't work like that (and it shouldn't).
    As Karthick pointed out, it's not a case that the IN clause is not working, it's a case of you not understanding the difference between the IN clause requiring a set of values as opposed to a single value, so you should read the FAQ link which points to useful information about how to deal with such situations.

  • Reinstalling HP s3400f to new condition if F11 is not working

    How do I Restore the PC to 'New' condition if my F11 is not working? I've changed keyboards and found that it's not the keyboard.
    I guess another question would be: How do I get the F11 button to work?

    You must start tapping the F11 key when you boot the computer if your trying to do a Factory Restore.  If you are running Vista it would be F10.
    Did you creater recovery disks when you first got the computer?
    Please mark my post as SOLVED if it has resolved your problem. It helps others with similar situations.

Maybe you are looking for

  • Video import crash

    I have been trying to import video into Priemer Pro (6) and every time I import a video that is longer than 5 minutes it crashes. If I go in and import individual files the audio imports fine, but video files causes it to crash. I have ran the latest

  • IMac (2007 flat screen) start up failure

    Failure before tone and grey screen, I hear the disk start and then the device produces a series of beeps, 3 short, 3 long, followed by three short; repeats every minute or so.

  • How Can I say "thank you" to the iMovie Team? Someone forward it to them?

    My son died Sunday. In the middle of incredible grief, I needed to make a video of stills of his life. I had never touched iMovie (or iDVD) before. I was able to stumble through every thing I needed to do and get it done against a very tight deadline

  • TS1368 Itunes Store trouble :/

    I can't get onto the itunes Store. It says it's loading for awhile... then says can not connect in the united states or something like that. IDK what to do.

  • Tiny Font in PowerPivot Field List

    PowerPivot looks like a powerful tool for my users but I can't introduce it to them with such a tiny font in the pivot table field list. I'm using Windows 7, 1920x1200 screen resolution, Excel 2010 (EN-US), and PowerPivot 10.50.1747.0. Raising the ma