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

Similar Messages

  • 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

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

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

  • 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||'''%''';

  • How to change the SQL-Query in (Report in ReportViewer) by running Java App

    Hello,
    Ich have an App which generates dynamicly SQL-Queries. By pressing a button it should generate a report with this generated Query.
    I´m using the ReportViewer.jar. Further is it possilbe to a extra parameters form app which are not in a DB?

    <p>There are a few ways that you can achieve this. If your SQL Queries have their filters modified (ie. WHERE clause) then this can be easily solved by adding report parameters to the Report filter. Search the in-product help for "Record Filter" and you should get a number of helpful resources returned.</p><p>Additionally, you can pass in java.sql.ResultSet objects with a populated recordset of the data you want to show in the report. We don&#39;t currently provide any tools to assist the creation of the code stubs for thick-client applications (like we do for JSP pages) however you can download a collection of thick-client sample code from here:</p><p><a href="http://support.businessobjects.com/communityCS/FilesAndUpdates/crxi_r2_jrc_desktop_samples.zip">http://support.businessobjects.com/communityCS/FilesAndUpdates/crxi_r2_jrc_desktop_samples.zip</a> </p><p>As I mentioned, this sample contains a collection of code snippets. The one in particular you will be interested in is titled "JRCResultsetDatasource". Hopefully, this will provide you with a few options. </p><p>Regards,<br />Sean Johnson (CR4E Product Manager) </p>

  • How to change access path for 'where' clause by using HINTS?

    I searched a loooot of posts and haven't found a solution for my case. I don't even know whether it is possible or not. Is it possible to change the sequence of Oracle "Predicate Information"?
    Here is my SQL and Oracle's execution plan.
      SELECT Max(logId) AS logId FROM online_users_t
      WHERE online_users_date >= to_date('2011-09-19 10:00:00') - 3.2 AND online_users_date <= to_date('2011-09-19 10:00:00') AND online_users_result in (1, -1)
      GROUP BY online_users_user
    | Id  | Operation                    | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                    | 24800 |   629K|  1336   (1)| 00:00:17 |
    |   1 |  HASH GROUP BY               |                    | 24800 |   629K|  1336   (1)| 00:00:17 |
    |*  2 |   TABLE ACCESS BY INDEX ROWID| ONLINE_USERS_T     | 38833 |   985K|  1334   (1)| 00:00:17 |
    |*  3 |    INDEX RANGE SCAN          | ONLINE_USERS_T_IDX |   116K|       |   313   (1)| 00:00:04 |
    Predicate Information (identified by operation id):
       2 - filter("ONLINE_USERS_RESULT"=(-1) OR "ONLINE_USERS_RESULT"=1)
       3 - access("ONLINE_USERS_DATE">=TO_DATE(' 2011-09-16 05:12:00', 'syyyy-mm-dd
                  hh24:mi:ss') AND "ONLINE_USERS_DATE"<=TO_DATE(' 2011-09-19 10:00:00', 'syyyy-mm-dd
                  hh24:mi:ss'))I have 2 conditions in my 'where' clause, one is date range and the other is 'online_users_result in (1, -1)'. It seems that Oracle filter the table by using 'online_users_result in (1, -1)' first, then access it through date range.
    What I want to do is firstly filtering the table by using date range followed by other things. How can I do it?
    Any clue or help would be highly appreciated.
    Thanks in advance.

    It seems that Oracle filter the table by using 'online_users_result in (1, -1)' first, then access it through date range. No it's not.
    What I want to do is firstly filtering the table by using date range followed by other things. How can I do it?That's precisely what it's doing now.
    It is using the T_IDX index to quickly find all rows that satisfy the range predicate on the date column.
    And then filter those rows to only retrieve the ones that satisfy the other predicate (... in (1,-1)).

  • Teradata Source SQL Server where clause In SSIS

    Hi All,,
    I want pull the data from Teradata to SQLServer .But Teradata source query in where clause around 200 productcodes manually. Instead of that one I want pass sqlserver table dynamically . creating  one temp table in ssis for sqlserver data and  
    Teradata source query joining the temp table (with out where clause) Is it possible to implement this task in SSIS or
    Best method to implement this task in ssis
    Thanks
    CMK...

    Hi CMK,
    You can create a staging table to store the productcodes used in the WHERE clause in the Teradata source query. Then, you can use Lookup Transformation in SSIS to achieve your goal.
    If you use Enterprise or Developer Edition of SSIS 2008 or higher, you can install the Microsoft Connector Version for Teradata by Attunity to obtain the OLE DB provider for Teradata. You can use an OLE DB Source adapter to extract data from the Teradata
    database without WHERE clause, then add a Lookup Transformation which lookups records from the staging table, and output the lookup match records to the destination SQL Server table.
    Reference:
    https://www.simple-talk.com/sql/ssis/implementing-lookup-logic-in-sql-server-integration-services/
    Regards,
    Mike Yin
    TechNet Community Support

  • 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

  • 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

  • Derive found flag in SQL with where clause using TABLE(CAST function

    Dear All,
    Stored procedure listEmployees
    ==========================
    CREATE OR REPLACE TYPE STRING_ARRAY AS VARRAY(8000) OF VARCHAR2(15);
    empIdList STRING_ARRAY
    countriesList STRING_ARRAY
    SELECT EMP_ID, EMP_COUNTRY, EMP_NAME, FOUND_FLAG_
    FROM EMPLOYEE WHERE
    EMP_ID IN
    (SELECT * FROM TABLE(CAST(empIdList AS STRING_ARRAY))
    AND EMP_COUNTRY IN
    (SELECT * FROM TABLE(CAST(countriesList AS STRING_ARRAY))
    =================
    I have a stored procedure which lists the employees using above simple query.
    Here I am using table CAST function to find the list of employees in one go
    instead of looping through each and every employee
    Everything fine until requirements forced me to get the FOUND_FLAG as well.
    Now I wanted derive the FOUND_FLAG by using rownum, rowid, decode functions
    but I was not successful
    Can you please suggest if there is any intelligent way to say weather the
    row is found for given parameters in the where clause?
    If not I may have to loop through each set of empIdList, countriesList
    and find the values individually just to set a flag. In this approach I can’t use
    the TABLE CAST function which is efficient I suppose.
    Note that query STRING_ARRAY is an VARRAY. It is very big in size and this procedure
    suppose to handle large sets of data.
    Thanks In advance
    Regards
    Charan
    Edited by: kmcharan on 03-Dec-2009 09:55
    Edited by: kmcharan on 03-Dec-2009 09:55

    If your query returns results, you have found them... so your "FOUND" flag might be a constant,...

  • Issue with using SHUTTLE in query where clause

    Lets say we have a shuttle control on the page with the following 4 values: apple:orange:peach:berry
    Lets say I also have a simple SQL query report on the page and I want to use between 1 and 4 of the aforementioned values as part of an "*IN LIST*" sql operation. For example, if the user has selected only apple and orange from the shuttle, I want my query to be:
    select * from some_table where fruit IN ('apple', 'orange');
    if however, the user has selected all 4 fruits, the query should then read:
    select * from some_table where fruit IN ('apple', 'orange', 'peach', 'berry');
    I will add the dilemma that I do not want to convert this query to become a PL/SQL based report. Rather, I want to leave it alone as a SQL Query. My initial attempt was to create a hidden item on the page and use APEX_UTIL.STRING_TO_TABLE with a loop to convert the shuttle data to a comma separated list. This worked great, however when I use the this hidden item in my query, it doesn't work properly. I hope I am explaining this well, but when I populate this hidden item, I will get something like this.
    apple,orange
    Great. Lets say the hidden item above is called P7_HIDDEN_VALUE (for example). I then try to reference it in my query, and here is the problem:
    select * from some_table where fruit IN (:P7_HIDDEN_ITEM)
    Do you see the problem. The item resolves itself to be apple,orange, when it really needs the quotes to be *'apple','orange'*
    Help!!!!

    Hi,
    This post might help
    How to enable user to pick which row without using filter in interact. rpt?
    Or Bens blog post
    http://munkyben.wordpress.com/2010/11/16/handling-aggregated-strings-in-sql-reports/
    Regards,
    Jari

  • JBO datasources: avoiding literal SQL in where clause

    I understand that it is possible to set the where clause when defining a datasource with datatags:
    e.g.
    <jbo:DataSource id="ds" appid="wms_bc4j.Wms_bc4jModule" viewobject="WebUsersView" whereclause="USER_ID = 1"/>
    However this results in literal SQL being sent to the database. Does anyone know of a method of using bind variables in this instance and thus avoid the literal SQL?

    Hi,
    You need to "CAST" the bind variable to get the comma separated individual values.
    Check this out article (Search for Using Comma-Separated String Bind for Variable IN List) on how to achieve this.
    It has been developed on 10g. But, i think it will hold good for 11g as well.
    -Arun

  • 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

Maybe you are looking for