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

Similar Messages

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

  • PL/SQL Evaluation problem of where clause in case of  NUMBER column type

    I found the following problem in Oracle® Database 2 Day Developer's Guide 11g Release 1 (11.1) B28843-04:
    The sole parameter of function eval_frequency is employee_id IN employees.employee_id%TYPE.
    An ORA-01422 exception occurs when the execution reaches the following select command
    SELECT e.hire_date
    INTO hire_date
    FROM employees e
    WHERE employee_id= e.employee_id;
    A possible cause of the error is that the type of employee_id is NUMBER while the employees.employee_id is NUMBER(6,0) . The result of the selection is the same as there were no WHERE clause at all.
    Everything worked fine, when I declared a temporary variable of NUMBER(6,0) for storing the actual parameter of function and used this variable in the where clause, but I consider this "solution" as being no solution.
    It is pointless to use %TYPE parameter of a function for flexibility if I must degrade this flexibility by a fixed declaration of a temporary variable of the same type as the column in question.
    What is wrong?
    The Developer'Guide I used, the Oracle Sql Developer I used or the PL/SQL version ?

    Hi,
    Welcome to the forum!
    user8949829 wrote:
    A possible cause of the error is that the type of employee_id is NUMBER while the employees.employee_id is NUMBER(6,0) . The result of the selection is the same as there I don't think so. The variable employee_id is defined as having the exact same type as the eponymous column. Even if it didn't, I believe Oracle will always implicity convert between datatypes when possible, rounding if necessary. That may cause errors, but it isn't causing this error.
    No, the error has nothing to do with the data type. It has to do with the ambiguity of employee_id: is it a column, or is it a variable?
    The default is that it means the column name, so
    WHERE   employee_id = e.employee_idis equivalent to saying
    WHERE   e.employee_id = e.employee_idwhich isn't quite the same thing as not having a WHERE clause; rows with NULL employee_id would still be excluded, if there were any.
    I think it's best not to use variable names that are the same as column names. You could call the variable v_employee_id, or, since it's an IN-argument, in_employee_id.
    If you must use a variable that can be mistaken for a column, then qulaify it with the name of the procedure, like this:
    WHERE   eval_frequency.employee_id = e.employee_id
    Everything worked fine, when I declared a temporary variable of NUMBER(6,0) for storing the actual parameter of function That makes sens. You probably gave that variable a name that couldn't be mistaken for a column in the table.
    Edited by: Frank Kulash on Jan 12, 2011 8:27 PM

  • 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

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

  • Case or Decode in the Where clause

    Dear all,
    My requirement is:
    If user select other then "ALL"option from the LOV the following condition should be part of the where clause.
    current_req_status = :block1.req_statusIf user select "ALL" from the lov no need to append the above condition in the where clause.
    Please give me the sample code
    select request_id,doc_name,doc_code,part_id,current_req_status from  test_table
    where req_type = 'I'
    and doc_code = :BLOCK1.doc_code
    and  -- Here is the condition is changed based on
            the :BLOCK1.req_status(LOV).
         -- If user select other then  "All" option from
            this LOV the query append the below condition
            current_req_status = :block1.req_status
          -- Else no need append the above condition
             in the query where clause.Edited by: roots on Apr 10, 2012 9:31 AM
    Edited by: roots on Apr 10, 2012 9:38 AM

    Hi InoL,
    In the database column not having "ALL" value inside. so the match does not return any values.
    My LOV has "A1,A2,A3,A4,....ALL" . the database column having "A1,A2,A3,A4.......". here no "ALL" value.
    So if user select "ALL" option from this LOV, that means select all vaules from the database (A1,A2,A3,A4......)..
    If user select A1 from the lov the select query include only the matched
    column values.from example,
    select....
    where  nvl(database_column,'X')= nvl(:Block1.LOV_value)If user select "ALL" option then no need for above condition in the where clause so that query returns all the rows from the database column.
    hope I've clearly explain my requirement.
    Thanks lot,
    Roots.

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

  • Case condition in where clause

    Hi
    I'm a SQL beginner but according to my reading of the manual, this syntax should be acceptable. I'm using it in application express but tested it also in SQL developer and finding that it fails with an "invalid relational operator" error, with the line number pointing to the ELSE clause of the CASE condition, but a column number pointing to white space.
    This is a nested select but that shouldn't matter. The fragment in question is this:
    select some columns
    from res
    where res.villaid = :P605_VILLAID
    and INSTR(:P604_RES_STATES, res.states) != 0
    and (CASE :P604_EXCLUDE_ZERO
    WHEN 'Y' THEN 'res.rate > 0'
    ELSE 'res.rate >= 0'
    END)
    and res.DEPARTDATE > :P605_STARTDATE
    and res.ARRIVEDATE <= :P605_ENDDATE,
    I hope this formats ok when posted. The code is looking for reservations in a date range (which works fine when the other conditions are commented out), and should only output zero-rate rows (complimentary nights) if the user asks for this in the P604_EXCLUDE_ZERO bind variable. There are probably other ways to go about this, but I am too stubborn to give up on this. Well, not yet anyway.
    Thanks and regards
    CS

    select some columns
      from res
    where res.villaid = :p605_villaid
           and instr (:p604_res_states, res.states) != 0
           and sign (res.rate) >= case when :p604_exclude_zero = 'Y' then 1 else 0 end
           and res.departdate > :p605_startdate
           and res.arrivedate <= :p605_enddate

  • Please help to build an sql from the given expression to build case condition with Where clause

    if  @rollno is not null then
    Select top  1 studentid  from student where rollno =:@rollno
    else
    if @regno is not null then
    Select top  1 studentid  from student where regno =:@regno
    Please help me to create  the above condition as  a single  sql statement . I will pass two argument in to the sql.
    With Thanks
    Pol
    polachan

    Select top 1 studentid from student
    where (rollno =:@rollno or :@rollno is null)
    and (regno =:@regno or :@regno is null)
    The above expression will work in SQL server
    I'm not sure you're using sql server as syntax like :@regno are not t-sql valid
    so you can try the above and if it doesnt work please try in the relevant forums for more help in case you're using a different RDBMS
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Need multiple Condition in Where Clause

    Hi,
    I have a table like below
    CREATE TABLE LedgerTable (Particulars varchar(200),Debit decimal(18,3), Credit decimal(18,3), Category varchar(200));
    INSERT into LedgerTable (Particulars, Debit, Credit, Category) values
    ('Asset', 0,80, 'Class'), ('CASH1', 0,100, 'Control'),('CASH2', 0,0, 'Control'),('Fittings', 20,0, 'Control'),('Furniture', 0,0, 'Control')
    i have a flag @suppressZero.
    If its 1 then need the result like below 
    i need to use @suppressZero in where condition
    Thanks and Regards
    Kasim

    Hi Latheesh,
    Thanks, but in my scenario i need to display record with category='Class' even if its 0 but not 'Control'
    i changed this like below
    elect * From LedgerTable Where (@suppressZero =1 and (Debit + Credit >0) or Category='Class') OR (@suppressZero=0)
    anyway thanks again

  • How to use maximum date condition in where clause ?

    Hi I want to check if SWITCH_FLAG has 'Y' for the latest batch run..how can write it?
    (select a.SWITCH_FLAG
    from MORTGAGE
    where SYS_EFF_DATE = max(SYS_EFF_DATE)
    ) as expected_result
    Error message:
    ORA-00934: group function is not allowed here

    This will give you the switch_flag for the latest eff_date,
    SELECT SWITCH_FLAG
      FROM (SELECT A.SWITCH_FLAG, ROW_NUMBER () OVER (ORDER BY SYS_EFF_DATE DESC) rn
              FROM mortgage A)
    WHERE rn = 1;
    --if you want to test try this,
    SELECT SWITCH_FLAG,SYS_EFF_DATE
      FROM (SELECT A.SWITCH_FLAG,SYS_EFF_DATE , ROW_NUMBER () OVER (ORDER BY SYS_EFF_DATE DESC) rn
              FROM mortgage A)
    WHERE rn = 1;G.

  • Retrieve List Items based on condition in Where Clause

    Hello Experts,
     I am trying to retrieve list items from a list (CityList)  which contains 2 columns one is city(string) and State(Lookup) based on Lookup value, but i am getting all city names.
    here is my query below.
    function MainFunction() {
            var lookupid = 5;
            var myQueryString = "<Where><Eq><FieldRef Name='State' LookupId='true' /><Value Type='Lookup'>"+lookupid+"</Value></Eq></Where>";
            var myContext = new SP.ClientContext.get_current(); ;
            var myWeb = myContext.get_web();
            var myList = myWeb.get_lists().getByTitle("CityList");
            var myQuery = new SP.CamlQuery();
            myQuery.set_viewXml(myQueryString);    
            myItems = myList.getItems(myQuery);
            myContext.load(myItems, 'Include(Title)'); 
            myContext.executeQueryAsync(Function.createDelegate(this, GetListDataSuccess), Function.createDelegate(
    this, GetListDataFail));
        function GetListDataFail(sender, args) {
            // Show error message
            alert('GetListDataFail() failed:' + args.get_message());
        function GetListDataSuccess(sender, args) {
            var currListItemCount = myItems.get_count();       
            var currItemEnumerator = myItems.getEnumerator();
            var currItemDetails = '';       
            while (currItemEnumerator.moveNext()) {          
                var currItem = currItemEnumerator.get_current();          
                 currItemDetails = currItemDetails + ';' + currItem.get_item("Title");
            // Show details 
            alert(currItemDetails); 
    Please suggest where i am wrong. 
    Thank you
    saroj

    You need to enclose the <Where> tag inside <View><Query> . Try like below
    var myQueryString = "<View><Query><Where><Eq><FieldRef Name='State' LookupId='TRUE' />
    <Value Type='Lookup'>"+lookupid+"</Value></Eq></Where></Query></View>";
    Geetanjali Arora | My blogs |

  • Using case when statement or decode stament in where clause

    hi gems..
    i have a problem in the following query..
    i am trying to use case when statement in the where clause of a select query.
    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
    cr.salary as salary
    from customer_details cr
    where (case when '>' = '>' then 'cr.salary > 5000'
    when '>' = '<' then 'cr.salary < 5000'
    when '>' = '=' then 'cr.salary = 5000'
    else null
    end);
    the expression in the when clause of the case-when statement will come from UI and depending on the choice i need to make the where clause.
    thats why for running the query, i have put '>' in that place.
    so the original query will look like this(for your reference):
    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
    cr.salary as salary
    from customer_details cr
    where (case when variable = '>' then 'cr.salary > 5000'
    when variable = '<' then 'cr.salary < 5000'
    when variable = '=' then 'cr.salary = 5000'
    else null
    end);
    so, in actual case,if the user selects '>' then the filter will be "where cr.salary > 5000"
    if the user selects '<' then the filter will be "where cr.salary < 5000"
    if the user selects '=' then the filter will be "where cr.salary = 5000"
    but i am getting the error "ORA 00920:invalid relational operator"
    please help..thanks in advance..

    Hi,
    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
           cr.salary                                      as salary
    from customer_details cr
    where (    v_variable = 'bigger'
           and cr.salary > 5000
       or (    v_variable = 'less'
          and cr.salary < 5000
       or (    v_variable = 'eq'
            and cr.salary = 5000
           )Edited by: user6806750 on 22.12.2011 14:56
    For some reason I can't write in sql '<', '>', '='

  • Case statement in where clause ??

    Hello gurus,
    Can we use case statements in where clause ?? Any example will be great!
    And also i would like to know, besides CASE and DECODE statements, Is there any way we can use IF ELSE statements in SELECT clause or in WHERE clause ?
    Thank you!!

    Hi,
    user642297 wrote:
    Hoek,
    Thanks for the reply
    Whatever you return from 'then' should match your criteria.I didnt get this part...can you elaborate this part ?? Thank you!!Remember what a CASE expression does: it returns a single value in one of the SQL data types (or NULL).
    You're probably familiar with conditions such as
    WHERE   col = 1Inthe example above, col could be replaced by any kind of expression: a function call, and operation (such as "d * 24") or a CASE expression, which is exactly what Hoek posted:
    where  case
             when col = 6 then 1
             when col = 9 then 1
           end = 1;I think what Hoek meant about mnatching was this: since the CASE expression is being compared to a NUMBER, then every THEN clause (as well as the ELSE, if there is one) should return the same data type. You can't have one THEN clause return a NUMBER, and another one in the same CASE expression return a DATE, like this:
    where  case
             when col = 6 then 1
             when col = 9 then SYSDATE     -- WRONG! Raises ORA-00932: inconsistent datatypes
           end = 1; 
    By the way, it's rare when a CASE expression really helps in a WHERE clause. CASE is great for doing conitional stuff in places where you otherwise can't (in the ORDER BY clause, for example), but the WHERE clause was designed for conditions.
    Hoek was just trying to give a simple example. If you really wanted those results, it would be simpler to say:
    where  col = 6
    or     col = 9and simpler still to say
    where  col  IN (6, 9)

Maybe you are looking for

  • How to aware a DN that has been copied to AR draft

    Dear all, When they copy a DN to an A/R, the DN is still open and the system will allow us to copy it to another A/R draft. I know if we add one A/R, the others include that DN the system will not allow us to add it. The problem is, sometimes they ha

  • Thrown validation exception not being showed in jspx page

    Hi, I have a page with af:table which uses one view object.That view object is using one entity object. In one of the method of the EntityImpl class of my entity object i throw ValidationException.I debugged the application and i saw that it is throw

  • Messages not sending in Outlook

    Hi I hope someone can help, I have a talk21.com account that I use via Outlook 2010. I now cannot send messages from this account and is returning error 421 too many messages. I have tried to set up a new account but that does exactly the same. Does

  • Routines

    Hi All, We have two external system that we want to extract data from. We are using UDconnect for the new system and will use flat files for the old system. Problem is product code defined in both systems are different. We want to define the products

  • Hp 22fi ips monitor

    my hp pavilion 22fi monitor displays no signal when connected to ps3 via hdmi. what should i do?