CAML Query where clause on lookup field

I'm trying to pull back values that are greater then 5 from my list. I'm using a lookup column that stores the numbers. That column is using a count of another lookup column in another list.
<Query>
<Where>
<Gt><FieldRef Name='LookupColumn' /><Value Type='Lookup'>10</Value></Gt>
</Where>
</Query>
I'm not getting any results or errors back. Is there a syntax error or something missing?

You're missing a ">" on closing Value tag:
<Value Type='Lookup'>10</Value
should be:
<Value Type='Lookup'>10</Value>

Similar Messages

  • CAML query IN Clause limiation

    Hi All,
    I am trying to avoid joining the main document library list with another lookup custom list by first search the lookup custom list and get the document IDs to search them in the document library using IN clause.
    The problem with the IN clause is that it does not support more than 500 items, after than an exception is report "unable to handle search query".
    I am looking for the recommended solution for this problem.
    B.S. I have read an incomplete post "https://social.msdn.microsoft.com/Forums/sharepoint/en-US/350b2e9e-0c50-4887-85d0-b7e8bce9a3b8/caml-query-in-clause-problem?forum=sharepointdevelopmentprevious"
    that suggests dividing the IN statements into bulks of 500 items, but this did not work with me either.
    In my example:
    <Where> <In>
    <FieldRef Name="ProgId" />
    <Values>
    <Value Type='Number'>6</Value>
    -------------------more than 500 times.
    <Value Type='Number'>10006</Value>
    </Values>
    </In>
    </Where>
    Thanks,

    Hi,
    Please go through below link
    http://sharepoint.stackexchange.com/questions/80210/caml-query-limitation-of-values-in-in-operator
    Regards
    Soni K

  • CAML Query In Clause Problem

    Hi, 
    I'm using CAML query to retrieve data from custom list in SharePoint 2010 using In clause. I'm creating the <Value></Value> tag dynamically and its working fine. 
    But sometimes I get a weird, no data fetch, error. I investigated on this and get to know that CAML query In clause only allow you to add 500 <Value></Value> in <Values> tag. The moment you'll entered 501 value it will not return any
    data.
    I need to resolve this problem and I can't send fetch request to SharePoint list if someone  is of the view that I should break the clause and fetch first 500 then again 500 and so on. 
    Any help will be appreciated. 
    Thank you

    Hello Kashif,
    Can't you create extra <OR> blocks when you have more than 500 values?
    <OR>
    <OR>
    <First block 500 values>
    <Second block 500 values>
    </OR>
    <Third block rest of the values>
    </OR>
    If this is not possible, maybe you can add more of your CAML query.
    Jeroen Molenaar

  • ? Mail [12721] Error 1 performing query: WHERE clause too complex...

    Console keeps showing this about a zillion times in a row, a zillion times a day: "Mail [12721] Error 1 performing query: WHERE clause too complex no more than 100 terms allowed"
    I can't find any search results anywhere online about this.
    Lots of stalls and freezes in mail, finder/os x, and safari -- freqent failures to maintain a broadband connection (multiple times every day).
    All apps are slow, cranky with interminable beach balls getting worse all the time.
    anyone know what the heck is going on?

    Try rebuilding the mailbox to see if that helps.
    Also, how much disk space is available on your boot drive?

  • Change my sql query where-clause in an extended controller

    Hello,
    i am trying to change my sql query where-clause in an extended controller
    personAplListVO.setWhereClause(null); // first set to null
    personAplListVO.setWhereClauseParams(null); // first set to null
    personAplListVO.setWhereClause(personAplListVOWhereClause +
    newWhereClause);
    personAplListVO.setWhereClauseParams(whereClauseParams);
    personAplListVO.executeQuery();
    System.out.println(">>>>>>>>getQuery = " + personAplListVO.getQuery());
    when i get the query ( personAplListVO.getQuery()) after executeQuery(), the new newWhereClause values are missing.
    Also i am getting null from personAplListVO.getWhereClause() after executeQuery()
    as if the above code is not making any effect.
    any ideas why?
    Thank you

    Hello,
    My Query:
    /* Formatted on 2011/06/15 15:50 (Formatter Plus v4.8.8) */
    SELECT /*+ FIRST_ROWS */
    NULL AS selectflag, ppf.full_name AS person_name,
    ppf.first_name AS person_first_name, ppf.last_name AS person_last_name,
    ppf.email_address, addr.derived_locale, addr.address_id,
    phn.phone_number, phn.phone_id, ppf.date_of_birth, addr.address_line1,
    (SELECT COUNT (*)
    FROM per_all_assignments_f paf2,
    per_all_people_f ppf2
    WHERE paf2.assignment_type = 'A'
    AND :1 BETWEEN paf2.effective_start_date AND paf2.effective_end_date
    AND paf2.person_id = ppf2.person_id
    AND paf2.effective_start_date BETWEEN ppf2.effective_start_date
    AND ppf2.effective_end_date
    AND ppf2.party_id = ppf.party_id
    HAVING COUNT (*) > 0) AS jobs_applied_for,
    (SELECT MAX (paf.effective_start_date)
    FROM per_all_assignments_f paf,
    per_all_people_f ppf2
    WHERE paf.assignment_type = 'A'
    AND :2 >= paf.effective_start_date
    AND paf.person_id = ppf2.person_id
    AND paf.effective_start_date BETWEEN ppf2.effective_start_date
    AND ppf2.effective_end_date
    AND ppf2.party_id = ppf.party_id) AS last_application,
    ppf.person_id, ppf.effective_start_date, ppf.effective_end_date,
    DECODE (vac.manager_id, :3, 'Y', 'N') AS my_applicants,
    vac.NAME AS vacancy_name, vac.vacancy_id, paf.assignment_id,
    (SELECT /*+ push_subq */
    MIN (pasf.effective_start_date)
    FROM per_all_assignments_f pasf
    WHERE pasf.assignment_id = paf.assignment_id) AS application_date,
    paf.effective_end_date AS assignment_end_date,
    ast.user_status AS application_status, ast.assignment_status_type_id,
    vac.status AS vacancy_status, mgr.full_name AS recruiting_manager,
    mgr.person_id AS recruiting_manager_id,
    mgr.effective_start_date AS effective_start_date1,
    mgr.effective_end_date AS effective_end_date1,
    rec.full_name AS recruiter, rec.person_id AS recruiter_id,
    rec.effective_start_date AS effective_start_date2,
    rec.effective_end_date AS effective_end_date2,
    ppf.per_information_category, ppf.per_information1,
    ppf.per_information2, ppf.per_information3, ppf.per_information4,
    ppf.per_information5, ppf.per_information6, ppf.per_information7,
    ppf.per_information8, ppf.per_information9, ppf.per_information10,
    ppf.per_information11, ppf.per_information12, ppf.per_information13,
    ppf.per_information14, ppf.per_information15, ppf.per_information16,
    ppf.per_information17, ppf.per_information18, ppf.per_information19,
    ppf.per_information20, ppf.per_information21, ppf.per_information22,
    ppf.per_information23, ppf.per_information24, ppf.per_information25,
    ppf.per_information26, ppf.per_information27, ppf.per_information28,
    ppf.per_information29, ppf.per_information30,
    FLOOR
    (irc_location_utility.sdo_miles (iwp.geometry, loc.geometry, 0.01)
    ) AS distance_to_location,
    loc.location_id, loc.derived_locale AS derived_locale1,
    doc.document_id, doc.file_name,
    NVL2 (doc.document_id, 'Y', 'N') AS previewenabled,
    inp.notification_preference_id, ppf.attribute_category, ppf.attribute1,
    ppf.attribute2, ppf.attribute3, ppf.attribute4, ppf.attribute5,
    ppf.attribute6, ppf.attribute7, ppf.attribute8, ppf.attribute9,
    ppf.attribute10, ppf.attribute11, ppf.attribute12, ppf.attribute13,
    ppf.attribute14, ppf.attribute15, ppf.attribute16, ppf.attribute17,
    ppf.attribute18, ppf.attribute19, ppf.attribute20, ppf.attribute21,
    ppf.attribute22, ppf.attribute23, ppf.attribute24, ppf.attribute25,
    ppf.attribute26, ppf.attribute27, ppf.attribute28, ppf.attribute29,
    ppf.attribute30, TO_CHAR (ROWNUM) AS rownumber,
    TO_CHAR
    ((irc_utilities_pkg.get_recruitment_person_id (ppf.person_id, :4))
    ) AS root_person_id,
    TO_CHAR
    (irc_skills_matching_pkg.vacancy_match_percent
    (irc_utilities_pkg.get_recruitment_person_id (ppf.person_id,
    :5
    vac.vacancy_id,
    :6
    ) AS match_percent,
    ppf.party_id, paf.effective_start_date AS assignment_start_date,
    pov.vendor_id, pov.vendor_name, regatmpt.attempt_id AS reg_attempt_id,
    TO_NUMBER (DECODE (regatmpt.raw_score, -1000, NULL, regatmpt.raw_score)
    ) AS reg_attempt_score,
    NVL2
    (regatmpt.mastery_score,
    DECODE (GREATEST (regatmpt.mastery_score, regatmpt.raw_score),
    regatmpt.raw_score, 'P',
    'F'
    NVL2 (fnd_profile.VALUE ('IRC_REGISTER_TEST'),
    NVL2 (inp.attempt_id, 'A', 'N'),
    NULL
    ) AS reg_attempt_status,
    aplatmpt.attempt_id AS apl_attempt_id,
    TO_NUMBER (DECODE (aplatmpt.raw_score, -1000, NULL, aplatmpt.raw_score)
    ) AS apl_attempt_score,
    NVL2
    (aplatmpt.mastery_score,
    DECODE (GREATEST (aplatmpt.mastery_score, aplatmpt.raw_score),
    aplatmpt.raw_score, 'P',
    'F'
    NVL2 (vac.assessment_id, NVL2 (iad.attempt_id, 'A', 'N'), NULL)
    ) AS apl_attempt_status,
    hrl.meaning, hrl.lookup_type, hrl.lookup_code,
    iad.assignment_details_id, iad.considered AS considered,
    vac.business_group_id,
    NVL
    ((SELECT iav.manage_applicants_allowed
    FROM irc_agency_vacancies iav
    WHERE iav.vacancy_id = vac.vacancy_id
    AND iav.agency_id = fnd_profile.VALUE ('IRC_AGENCY_NAME')),
    'Y'
    ) AS manage_applicants_allowed,
    DECODE (paf.source_type, 'ER', 'Y', 'N') AS referred,
    ircreferralinfoeo.start_date, ircreferralinfoeo.end_date,
    (SELECT meaning
    FROM hr_lookups
    WHERE lookup_code = ircreferralinfoeo.source_type
    AND lookup_type = 'REC_TYPE') AS sourcetype,
    DECODE (ircreferralinfoeo.source_type,
    'ER', (SELECT full_name
    FROM per_all_people_f
    WHERE person_id = ircreferralinfoeo.source_person_id
    AND SYSDATE BETWEEN effective_start_date
    AND effective_end_date),
    ircreferralinfoeo.source_name
    ) AS sourcename,
    ircreferralinfoeo.object_id, ircreferralinfoeo.object_type
    FROM per_addresses addr,
    per_phones phn,
    per_all_people_f ppf,
    per_all_assignments_f paf,
    per_all_vacancies vac,
    per_assignment_status_types_v ast,
    per_all_people_f mgr,
    per_all_people_f rec,
    irc_notification_preferences inp,
    hr_locations_all_vl loc,
    irc_documents doc,
    irc_search_criteria iwp,
    per_all_people_f irc_ppf,
    po_vendors pov,
    ota_attempts regatmpt,
    irc_assignment_details_f iad,
    ota_attempts aplatmpt,
    hr_lookups hrl,
    irc_referral_info ircreferralinfoeo
    WHERE irc_utilities_pkg.get_recruitment_person_id (ppf.person_id, :7) =
    irc_ppf.person_id
    AND :8 BETWEEN ppf.effective_start_date AND ppf.effective_end_date
    AND irc_ppf.party_id = ppf.party_id
    AND ppf.person_id = paf.person_id
    AND paf.assignment_type = 'A'
    AND paf.vacancy_id = vac.vacancy_id
    AND :9 BETWEEN paf.effective_start_date AND paf.effective_end_date
    AND paf.assignment_status_type_id = ast.assignment_status_type_id
    AND irc_ppf.person_id = doc.person_id(+)
    AND irc_ppf.person_id = phn.parent_id(+)
    AND phn.parent_table(+) = 'PER_ALL_PEOPLE_F'
    AND phn.phone_type(+) = 'H1'
    AND :10 BETWEEN NVL (phn.date_from(+), :11) AND NVL (phn.date_to(+), :12)
    AND vac.manager_id = mgr.person_id(+)
    AND :13 BETWEEN mgr.effective_start_date(+) AND mgr.effective_end_date(+)
    AND vac.recruiter_id = rec.person_id(+)
    AND :14 BETWEEN rec.effective_start_date(+) AND rec.effective_end_date(+)
    AND irc_ppf.person_id = inp.person_id(+)
    AND inp.person_id = addr.person_id(+)
    AND NVL (inp.address_id, DECODE (addr.address_type(+), 'REC', addr.address_id(+),
    -1)) = addr.address_id(+)
    AND :15 BETWEEN addr.date_from(+) AND NVL (addr.date_to(+), :16)
    AND loc.location_id(+) = vac.location_id
    AND doc.TYPE(+) LIKE '%RESUME'
    AND doc.end_date(+) IS NULL
    AND irc_ppf.person_id = iwp.object_id(+)
    AND iwp.object_type(+) = 'WPREF'
    AND :17 BETWEEN irc_ppf.effective_start_date AND irc_ppf.effective_end_date
    AND ( inp.agency_id = fnd_profile.VALUE ('IRC_AGENCY_NAME')
    OR fnd_profile.VALUE ('IRC_AGENCY_NAME') IS NULL
    AND inp.agency_id = pov.vendor_id(+)
    AND inp.attempt_id = regatmpt.attempt_id(+)
    AND paf.assignment_id = iad.assignment_id(+)
    AND :18 BETWEEN iad.effective_start_date(+) AND iad.effective_end_date(+)
    AND iad.latest_details(+) = 'Y'
    AND iad.attempt_id = aplatmpt.attempt_id(+)
    AND hrl.lookup_type(+) = 'VACANCY_STATUS'
    AND vac.status = hrl.lookup_code(+)
    AND paf.assignment_id = ircreferralinfoeo.object_id(+)
    AND SYSDATE BETWEEN ircreferralinfoeo.start_date(+) AND ircreferralinfoeo.end_date(+)
    AND ( 1 = 1
    AND (NVL (doc.document_id, 1) =
    NVL ((SELECT MAX (idoc1.document_id)
    FROM irc_documents idoc1
    WHERE idoc1.person_id = irc_ppf.person_id
    AND idoc1.TYPE IN ('RESUME', 'AUTO_RESUME')
    AND idoc1.end_date IS NULL
    AND idoc1.last_update_date =
    (SELECT MAX (idoc2.last_update_date)
    FROM irc_documents idoc2
    WHERE idoc2.person_id = irc_ppf.person_id
    AND idoc2.TYPE IN
    ('RESUME', 'AUTO_RESUME')
    AND idoc2.end_date IS NULL)),
    1
    and my where clause that i want to append to the existing one:
    and ppf.sex = 'M' and ppf.nationality = '1680'
    my processFormRequest function in my extended CO
    public void processFormRequest(OAPageContext pageContext,
    OAWebBean webBean) {
    super.processFormRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    String genderValue = pageContext.getParameter("gender");
    String nationality = pageContext.getParameter("nationality");
    ViewObject personAplListVO = am.findViewObject("PersonAplListVO");
    String personAplListVOWhereClause = personAplListVO.getWhereClause();
    Object[] whereClauseParams = personAplListVO.getWhereClauseParams();
    String newWhereClause = "";
    //gender
    if (genderValue != null && !genderValue.trim().equals("")) {
    newWhereClause += " and ppf.sex = '" + genderValue + "'";
    //nationality
    if (nationality != null && !nationality.trim().equals("")) {
    newWhereClause += " and ppf.nationality = '" + nationality + "'";
    System.out.println("\n>>>>>>>>getQuery = " + personAplListVO.getQuery());
    System.out.println("\n>>>>>>>>newWhereClause = " + newWhereClause);
    if (!newWhereClause.equals("")) {
    personAplListVO.clearCache();
    personAplListVO.setWhereClause(null); // first set to null
    personAplListVO.setWhereClauseParams(null); // first set to null
    personAplListVO.setWhereClause(personAplListVOWhereClause +
    newWhereClause);
    personAplListVO.setWhereClauseParams(whereClauseParams);
    personAplListVO.executeQuery();
    // System.out.println(">>>>>>>>newWhereClause" +
    // personAplListVOWhereClause + newWhereClause);
    // System.out.println(">>>>>>>>getWhereClause" +
    // personAplListVO.getWhereClause());
    // System.out.println(">>>>>>>>getQuery = " +
    // personAplListVO.getQuery());
    any tips?
    thanks a lot

  • Binding an SQL "where" clause to a field in the report.

    Hello everybody,
    I have made a crystal report that works fine. Now, I need to add a specific query to the report and drag and drop the returned fields in the report.
    The problem is that I need to add a query that contains a "Where" clause that is binded to a field already existing in the report, for example :
    SELECT T0.Field1,
                  T0.Field2,
                  T0.Field3
    FROM Table1 T0
    WHERE T0.Field4=(a field from a report)
    Is it possible to do it ? if yes, how can I do it.
    Thank you in advance for your further responds,
    Best Regards,
    - Youssef -

    Moved to Report Design forum
    You can't do it in that specific way. It would have to be done server side or use a subreport and then link the subreport on the field from the main report.
    Don

  • CAML query to return multi-user field from a Sharepoint list

    I have a list in SharePoint that contains a field of type Multi-User which can contain 1 to many user names. I'm having trouble returning a string containing anything when more then 1 user is selected in the field.  Can someone point me in the right
    direction?

    You can't query on a Mutli-user field using a "contains" filter - using the GUI. 
    However, you can change the CAML for the query using SharePoint Designer.
    E.g. In my view, I want to return a list of documents where the Contributor field (a multi-user field) contains the user "Warner".
    In the GUI, I create the view, but I'm not allowed to use the filter "Contains", so I use "Equals" instead. Of this won't work unless the only user is "Warner". So I open SharePoint Designer, and I change the query used on that view from Eq to Contains.
    Original query:
    <View Name="{D0E65C04-0A53-4C26-9004-68B3CFF1F11A}" MobileView="TRUE" Type="HTML" DisplayName="Warners Documents" Url="/Shared Documents/Forms/Warners Documents.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/dlicon.png?rev=23" >
    <Query>
    <Where>
    <Eq>
    <FieldRef Name="Contributors"/>
    <Value Type="Text">Warner</Value>
    </Eq>
    </Where>
    </Query>
    <ViewFields>
    <FieldRef Name="DocIcon"/>
    <FieldRef Name="LinkFilename"/>
    <FieldRef Name="Modified"/>
    <FieldRef Name="Editor"/>
    <FieldRef Name="Contributors"/>
    </ViewFields>
    <RowLimit Paged="TRUE">30</RowLimit>
    <Aggregations Value="Off"/>
    <JSLink>clienttemplates.js</JSLink>
    <XslLink Default="TRUE">main.xsl</XslLink>
    <Toolbar Type="Standard"/>
    </View>
    New Query:
    <View Name="{D0E65C04-0A53-4C26-9004-68B3CFF1F11A}" MobileView="TRUE" Type="HTML" DisplayName="Warners Documents" Url="/Shared Documents/Forms/Warners Documents.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/dlicon.png?rev=23" >
    <Query>
    <Where>
    <Contains>
    <FieldRef Name="Contributors"/>
    <Value Type="Text">Warner</Value>
    </Contains>
    </Where>
    </Query>
    <ViewFields>
    <FieldRef Name="DocIcon"/>
    <FieldRef Name="LinkFilename"/>
    <FieldRef Name="Modified"/>
    <FieldRef Name="Editor"/>
    <FieldRef Name="Contributors"/>
    </ViewFields>
    <RowLimit Paged="TRUE">30</RowLimit>
    <Aggregations Value="Off"/>
    <JSLink>clienttemplates.js</JSLink>
    <XslLink Default="TRUE">main.xsl</XslLink>
    <Toolbar Type="Standard"/>
    </View>
    This now works.
    However, the SharePoint team probably put this restriction in place for a reason. Possibly a performance related reason, due to the query performed on the SQL server, so use this method with caution.
    Regards, Matthew
    MCPD | MCITP
    My Blog
    View
    Matthew Yarlett's profile
    See my webpart on the TechNet Gallery that allows administrative users to upload, crop and format user profile photos. Check it out here:
    Upload and Crop User Profile Photos

  • How To change the ADF View Object  query where-clause at RunTime?

    I am trying to create a simple display page which will display user data (username, assoc_dist_id, assoc_agent_id, status , etc). The User data is stored in a database table and i am using an ADF Read Only table based on the View Object to display the data on the JSF page.
    However, i want to display only the users that a particular person accessing the page has the AUTH LEVEL to see. e.g. If the person accessing the page is an 'ApplicationAdministrator' then the page should display all users in the table, If its a 'DistributorAdministrator' then the page should display only users associated with that Distributor (i.e. assoc_dist_id = :p_Dist_id ) and If its an 'AgentAdministrator' , then the page should display only users associated with that Agent ( i.e. assoc_agent_id = :p_Agent_id).
    Currently my af:table component displays all the users in the table because the query for the view object is (select * from users) . However, i want to use the same viewobject and just set the where-clause at runtime with the appropriate parameter to restrict the dataset returned.
    Do anyone knows how to accomplish this ?

    David,
    See the custom method initializeDynamicVariableDefaults() in the SRViewObjectImpl.java class in the FrameworkExtentions project in the SRDemoSampleADFBC sample application. You can find out how to install the demo if you haven't already from the ADF Learning Center at:
    http://www.oracle.com/technology/products/adf/learnadf.html
    This class is a framework extension class for view objects that adds a neat, generic feature to be able to dynamic default the value of named bind variables. You can read more about what framework extension classes are and how to use them in Chapter 25, "Advanced Business Components Techniques" of the ADF Developer's Guide for Forms/4GL Developers, also available at the learning center above.
    It is an example of generic framework functionality that "kicks in" based on the presence of custom metadata properties on a named bind variable. See section 25.3.3 "Implementing Generic Functionality Driven by Custom Properties" in the dev guide for more details. Using this sample code, if you add a bind variable to a view object, and define a custom metadata property named "DynamicDefaultValue" on that bind variable, and set this custom metadata property to the value "CurrentUser", then that bind variable will have its value dynamically defaulted to the name of the authenticated user logged in. If instead you set this custom property to the value "UserRole", then the bind variable will be set to the comma-separated string containing the list of roles that the authenticated user is part of.
    Once you've created a framework extension class for view objects like this, you can have the view objects you create inherit this generic functionality.See section 25.1.4 "How to Base an ADF Component on a Framework Extension Class" in the dev guide for more info on this.
    By adapting a technique like this (or some idea similar that better suits your needs) you can have your view object query contain bind variables whose values automatically take on the defaults based on something in the user-session environment.

  • MDX query - need to run different query (where clause) on mondays

    The below query works OK and uses the substitution variable CurrentWeek in the WHERE clause, but I have one shortcoming that I need your help for:
    The query works fine for all days but mondays. On Mondays I need the query to fetch numbers from last week (as opposed to current week) as the query returns null as the cubes have no data for current week on mondays. Hence I need to change the where clause to use substitution variable LastWeek, or in some other way run a different query on mondays. I have another substitution variable called WeekDay which I can use to test which day of the week it is, but I am not sure of the syntax I need to use to test for day of week and then have the query use different substitution variables as a result of this test.
    Please help.
    Henning Strand
    SELECT NON EMPTY {[Measures].[meas_sg]} ON COLUMNS,
    NON EMPTY {[Kunde],[Kunde].[KU01],[Kunde].[KU02],[Kunde].[KU03],[Kunde].[KU04]} ON ROWS
    FROM MIFS.MIFS
    WHERE ([Marked].[Dagligvare],[Tid].[&CurrentWeek])

    Or to go off of Sean's suggestion, programmatically change the value of the substitution variable, and leave the code alone.
    Other thoughts -- have a load process to a single cell (sorry, my BSO roots are showing, but the concept is the same, load a single number) and then do a boolean test off its value -- 0 = Monday, 1 = the rest of the week.
    Regards,
    Cameron Lackpour

  • Linq to XML query where clause excluding null attribute in child

    I'm quite new to linq/XML and although I'm making progress I'm stuck at combining two levels of elements in a where clause. The XML is something like this
    <employees type="cashier">
    <employee hired="Jun 1 2000" fired="Jun 1 2013">
    <stats name="jane doe">
    ... other stuff ...
    <stats />
    <employee/> <employee hired="Jun 1 2000">
            <stats name="john doe">
                ... other stuff ...
            <stats />
        <employee/>
    <employees/>
    I'm trying to retrieve all employees of type "cashier" that haven't been fired.
    I tried this
    IEnumerable<XElement> CashierElements = from el in xDoc.Root.Descendants("employees")
    where (string)el.Attribute("type")=="cashier"
    && (string)el.Element("stats").Attribute("fired") != null
    select el;
    But that returns entries where the fired attribute doesn't exist. I'm not even sure I can reference the stats element attribute in this way but VS2013 doesn't complain about it.
    I have managed to muddle past by using two linq selections, the one above without the stats comparison followed by a second on the results that checks for "fired" being null.
    How would I achieve this with one select statement?
    Thanks!

    Hi,
    1) Your XML contains the attribute "fired" on "employee" element. Your query search this attribute on the "stats" element.
    2) you say "that haven't been fired" by you search an attribute fired != null ? I'm not sure about your logic.
    If I understand your request, your LINQ Query is more than :
    IEnumerable<XElement> CashierElements =
    // Loop on <employees>
    from emps in xDoc.Root.Descendants("employees")
    // only 'cashier' type
    where (string)emps.Attribute("type") == "cashier"
    // Loop on <employee> in filtered <employees>
    from emp in emps.Elements("employee")
    // only the employee not fired
    where emp.Attribute("fired") == null
    // select the employee element
    select emp;
    Regards
    Yan Grenier
    Merci de bien vouloir "Marquer comme réponse", les réponses qui ont répondues à votre question, et de noter les réponses que vous avez trouvé utiles.

  • Selecting values for query where clause

    hi guys, this is possibly a silly question but not sure if i am approaching the solution in the correct mannor.
    At the top of my form i have text box which the user fills in various values. These values are then used to refine the query results in the block below. I know i can go into the datablock being queried and set the where clause to equal the value of the text boxes above but i dont feel this is the right place to do it.
    If i do it that way when the text box above is blank it returns no reults when infact i want to query everything if the values are left blank. So should i put it in pre query? if so what way should it be done?
    Any help would be greatly appreciated.
    Thanks.

    Hello,
    If i do it that way when the text box above is blank it returns no reults when infact i want to query everything if the values are left blank. So should i put it in pre query? if so what way should it be done?Not really if you use like below in block's where clause...
    db_field_name1=NVL(:form_field_name1,db_field_name1) AND
    db_field_name2=NVL(:form_field_name2,db_field_name2)-Ammad

  • Change VO query where clause

    I need to change my VO query where and order by clause dynamically based on the selectOneChoice options. Any code example would be greately appreciated. I am using jdeveloper 11g, adf bc, oracle db.

    buildWhereClause() accepts 2 arguments; the first is the complete query, which you will have to change by adapting the WHERE clause. You do this after you call super.buildWhereClause().
    As far as calling it from a backing bean, you won't be able to call it directly. This method is called by the framework when the VO's query needs to be run. You can accomplish this by calling executeQuery() on the VO or the bould iterator.
    Now as far as passing your selectOneChoices' options, your selectOneChoices should be bound to your VO. Then you can access them from inside buildWhereClause().
    Nick

  • 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

  • Dynamic Query Where Clause

    Hi,
    I have the following query in a SQL Query (Pl/Sql Function Body Returning Sql Query) report:
    DECLARE
    q VARCHAR2(32767); -- query
    w VARCHAR2(4000) ; -- where clause
    we VARCHAR2(1) := 'N'; -- identifies if where clause exists
    BEGIN
    q:= 'SELECT "OSP_ID",' ||
    ' "OSP_NUMBER",'||
    ' "PROPOSAL_TITLE",'||
    ' "PROPOSAL_TYPE",'||
    ' "AGENCY_TYPE_CODE",'||
    ' "AGENCY_TYPE",'||
    ' "AGENCY_CODE",'||
    ' "AGENCY_NAME",'||
    ' "AGENCY_ABBREVIATION",'||
    ' "SPONSOR_CODE",'||
    ' "SPONSOR_NAME",'||
    ' "PI_NAME",'||
    ' "PI_EMP_NUMBER",'||
    ' "PI_PERS_ID" '||
    ' FROM "PROPOSAL_V" ';
    IF :P25_OSP_NUMBER != '-All-'
    THEN
    w := ' OSP_NUMBER = :P25_OSP_NUMBER ';
    we := 'Y';
    END IF;
    IF :P25_PROPOSAL_TYPE != '-1'
    THEN
    IF we = 'Y'
    THEN
    w := w || ' AND PROPOSAL_TYPE = :P25_PROPOSAL_TYPE ';
    ELSE
    w := ' PROPOSAL_TYPE = :P25_PROPOSAL_TYPE ';
    we := 'Y';
    END IF;
    END IF;
    IF we = 'Y'
    THEN q := q || ' WHERE '|| w;
    END IF;
    RETURN q;
    END;
    What I need is to change the ' OSP_NUMBER = :P25_OSP_NUMBER ';
    to ' OSP_NUMBER LIKE '%'||:P25_OSP_NUMBER'%'|| ';
    But I'm getting errors when I do like above.
    Can somebody please help...
    Thanks in advance
    - Pradeep

    First of all, get rid of that silly "where exists" variable, just add a where clause like where 1=1 to the query and keep adding dynamic clauses with AND clause as needed.
    Try
    q := q||'and OSP_NUMBER LIKE ''%'''||:P25_OSP_NUMBER||'''%''';

  • Column Security - Users can't see it, but need to use it in the query WHERE Clause

    I am looking at possible solutions (if any) on column security. We need to be able to restrict users from seeing certain columns, however, they will need these columns in the WHERE clause of queries.
    I thought about creating views, however, it would be a poor database design. Is there any way that this can be done on the database level. I know about Fine Granular Access Method, however, this just excludes the column completely. Which means that they can not be used in the WHERE clause.
    Any help would be greatly appreciated.
    Philip

    I too added 2nd apple ID when I tried to get Free app from apple store just to get to NONE on the credit card needed. It said it sent confirmation email to my new apple ID email that I have to confirm. Problem is I can not get to the new apple ID email account.  On my ipad it logs into my original email account and I see no where to log into another email account.  If I go to my laptop, the new apple ID I created does not let me log into email where apple said it was sent to.  It did not send to back up email account either.
    Can I log into 2 email accounts on my ipad where it says mail at bottom?
    Can I have 2 apple ids?
    If I created a 2nd apple id to get to NONE on credit card needed, can't I log into it also on another laptop in gmail?
    (won't let me)
    If I used my original apple id I created when I got my new ipad, it will not let me get free app without credit card, there is no where it says NONE needed. I am too new to apple to start with credit cards etc until I get use to it.

Maybe you are looking for

  • How can i add two emails under one account

    i have my primary apple email (that i used to purchase apps) and i need to add another email (work email) under my primary apple email so i can use the work email on my work iphone and it the same time download the apps that i purchased from app stor

  • Problems in using a certificate with  different versions of JVM

    Hi friends, I am facing a typical problem: I have to use a certificate which uses the sha1DSA signing algorithm to contact a web service(I am coding a client). I was using J2SDK_1.4.1_02 before. I added the certificate to keystore and it was working

  • Data level Security

    I need to implement data level security on the dashboards for users based on job hierarchy and region location since i have multiple subject areas this needs to be implemented on one subject area and reports and dashbord from the same subject area .

  • Downloading a file or a pricture by clicking on a button

    i am using visual studio 2013 i cant seem to find a tutorial on how to make a downloader or just a way to download a file through a link ...  any help? 

  • See my Case

    I have a MAC OSX 10.9.4   I can't open an image in PS Elements editor to edit it, from my iPHoto.  I have PS Elements selected in iPhoto preferences as my external editor. When I select the image in iPhoto and then select "Edit in External Editor" th