Generating a 'WHERE' clause using a function

Hi I have below requirement,
for given function below are input parameters,
sk_func(salary,dept_no,job,hire_date)
which ever input is given those inputs should be there in one statement,
For example if I give input as
select sk_func(5000,null,null,null) from dual;
I need output as Where salary=5000;
if I give input as
select sk_func(5000,null,'Programmer',null) from dual;
I need output as Where Salary=5000 and job='Programmer';
Hope am clear,
In short which ever values are not null, those all should include in my where clause,
I know how to do it, but taking into considerations, am finding the best way to do it,
Thanks for your responses,

Hi Karthik,
this is the api, I have done,
create or replace
FUNCTION get_where_clause_for_emp_req (
   emp_id       IN   NUMBER,
   salary            IN   NUMBER,
   job         IN   VARCHAR2,
   dept IN NUMBER
   RETURN VARCHAR2
IS
   l_where_clause   VARCHAR2 (2000);
BEGIN
   IF (    (emp_id IS NULL)
       AND (salary IS NULL)
       AND (job IS NULL)
       AND (deptIS NULL)
   THEN
      RETURN NULL;
   ELSE
      l_where_clause := 'WHERE ';
   END IF;
   IF (emp_id IS NOT NULL)
   THEN
      l_where_clause :=
                    l_where_clause || ' emp_id =' || emp_id || '';
   END IF;
   IF ((emp_id IS NOT NULL) AND (salary IS NOT NULL))
   THEN
      l_where_clause :=
                      l_where_clause || ' AND salary= ' || salary;
   ELSIF (salary IS NOT NULL)
   THEN
      l_where_clause := l_where_clause || ' salary= ' || salary;
   END IF;
   IF (((salary IS NOT NULL) AND (dept IS NOT NULL)) OR ((emp_id IS NOT NULL) AND (salary IS NULL) AND (dept IS NOT NULL)))
   THEN
      l_where_clause := l_where_clause || ' AND dept= ' || dept;
   ELSIF (status_i IS NOT NULL)
   THEN
      l_where_clause := l_where_clause || ' dept= ' || dept;
   END IF;
l_where_clause := l_where_clause || ' ;';
   RETURN l_where_clause;
END;I have done for three parameters, i need to include two more input parameters for this function, so I see going forward my testing cases will increases,
so am looking for the best solution
Thanks
Edited by: NSK2KSN on Jul 7, 2010 3:11 PM

Similar Messages

  • Generate a where clause with outer join criteria condition: (+)=

    Hi,
    In my search page, I use Auto Customization Criteria mode, and I build where clause by using get Criteria():
    public void initSrpQuery(Dictionary[] dic, String userName) {
    int dicSize = dic.length;
    StringBuffer whereClause = new StringBuffer(100);
    Vector parameters = new Vector(5);
    int clauseCount = 0;
    int bindCount = 1;
    for(int i=0; i < dicSize; i++){
    String itemName = (String)(dic.get(OAViewObject.CRITERIA_ITEM_NAME));
    Object value = dic[i].get(OAViewObject.CRITERIA_VALUE);
    String joinCondition = (String)dic[i].get(OAViewObject.CRITERIA_JOIN_CONDITION);
    String criteriaCondition = (String)dic[i].get(OAViewObject.CRITERIA_CONDITION);
    String criteriaDataType = (String)dic[i].get(OAViewObject.CRITERIA_DATATYPE);
    String viewAttributename = (String)dic[i].get(OAViewObject.CRITERIA_VIEW_ATTRIBUTE_NAME);
    String columnName = findAttributeDef(viewAttributename).getColumnNameForQuery();
    if((value != null) /*&& (!("".equals((String).trim())))*/){
    if(clauseCount > 0){
    whereClause.append(" AND ");
    whereClause.append(columnName + " " + criteriaCondition + " :");
    whereClause.append(++bindCount);
    parameters.addElement(value);
    clauseCount++;
    If I want to generate following where clause:
    select
    ,emp.name
    ,emp.email
    ,emp.salesrep_number
    ,comp.name
    ,gs.srp_goal_header_id
    ,gs.status_code
    ,gs.start_date
    ,gs.end_date
    from g2c_goal_shr_emp_assignments_v emp
    ,jtf_rs_salesreps rs
    ,xxg2c_srp_goal_headers_all gs
    ,cn_comp_plans_all comp
    where 1 = 1
    and rs.salesrep_id = gs.salesrep_id (+)
    and gs.comp_plan_id = comp.comp_plan_id (+)
    and gs.period_year (+) = :1 -- :1 p_fiscal_year
    How can I generate a where clause with outer join : gs.period_year (+) = :1 ? Will I get '(+)=' from get(OAViewObject.CRITERIA_CONDITION)?
    thanks
    Lei

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

  • How can you add a where clause using "OR" with applied ViewCriteria?

    [JDeveloper 10.1.3 SU4]
    [JHeadstart 10.1.3 build 78]
    I am using JHeadstart, but have a question probably more in the ADF area. On the JHeadstart forum I asked:
    "I am overriding JhsApplicationModule's advancedSearch in order to be able to search in childtables. I created transient attributes, display those in advanced search and in the overridden method I check if any of these are filled by the user and create a where clause like 'EXISTS (SELECT 1 FROM <childtable> WHERE <column in childtable> = <column in EO's table> AND <another column in childtable> LIKE '<value supplied by user>)'. I add this whereclause using ViewObject.setWhereClause.
    So far so good and it works. However, if the user selects 'Result matches any criteria', combining setWhereClause and the normal advancedSearch QueryByExample implementation using ViewCriteriaRow do not provide the desired result, since the ViewCriteria and the setWhereClause are AND-ed together, which is fine if the user selects the (default) "Results match all criteria" (everything is AND-ed) but not the "Result matches any criteria", since then every criterium is OR-ed together, except for the setwhereclause criteria and the set of ViewCriteriaRows, they are AND-ed.
    I looked if I could specify that a WhereClause will be OR-ed to existing applied ViewCriteria, but no luck. Do I have to rewrite also advancedSearch's ViewCriteria implementation and write an entire setWhereClause implementation to be able to "OR" every criterium? Or any other suggestions? Can I look at the entire Where clause and rewrite it (after applyCriteria and setWhereClause are called on the VO)?
    Toine"
    Sandra Muller (JHeadstart Team) told me today: "This sounds like a JDeveloper/ADF issue that is not related to JHeadstart. The question is: how can you add a where clause using "OR" if there are already one or more ViewCriteria applied?
    To simplify the test case, you could create a simple ADF BC test client class in a test Model project without JHeadstart (in the test class, use bc4jclient + Ctrl-Enter), in which you first apply a few ViewCriteriaRows to a View Object and also add a where clause.
    Can you please log a TAR at MetaLink ( http://metalink.oracle.com/ ), or ask this question at the JDeveloper forum at http://otn.oracle.com/discussionforums/jdev.html ? (This what I am doing now ;-))
    Thanks,
    Sandra Muller
    JHeadstart Team
    Oracle Consulting"
    Anyone knowing the answer or am I asking for an enhancement?
    Toine

    Hi,
    Can you SET your whereclause as follows ?
    ('Y' = <isAnd>
    and EXISTS (SELECT 1 FROM <childtable> WHERE <column in childtable> = <column in EO's table> AND <another column in childtable> LIKE '<value supplied by user>))
    OR ('N' = <isAnd>
    AND EXISTS (SELECT 1 FROM <childtable> WHERE <column in childtable> = <column in EO's table> OR <another column in childtable> LIKE '<value supplied by user>))
    )

  • How can and where i use the function "HTMLDB_UTIL.CLEAR_PAGE_CACHE "

    how can and where i use the function "HTMLDB_UTIL.CLEAR_PAGE_CACHE " ?
    where is the place to put this function?

    i have notice that sometime, during visual a report of a table, order by data insert desc, some record are not displayed on some client.
    Only whe we clear the cache of internet explorer than this record can view.
    I have an idea that a clear page when i call the report may be solve the problem.
    Thank's.
    ------------------------

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

  • Generating HANA where clause for select options having CP as the operator

    Hi All
    I am trying to generate where clause in HANA sql from the select options range table .
    I tried using the function modules  RSDS_RANGE_TO_WHERE and  RH_DYNAMIC_WHERE_BUILD .
    They are working for most of the cases . But  , when the range table has entries like
    Fieldname   sign opt  low high
    VBELN        I/E    CP  *4*
    Both of them fail to generate the right result .
    Could you suggest any other function modules , which take care of all such cases like include single values , exclude single values , incluse and excluse ranges , patterns etc .
    Thanks and Best Regards
    Varsha

    Hi Karthik,
    this is the api, I have done,
    create or replace
    FUNCTION get_where_clause_for_emp_req (
       emp_id       IN   NUMBER,
       salary            IN   NUMBER,
       job         IN   VARCHAR2,
       dept IN NUMBER
       RETURN VARCHAR2
    IS
       l_where_clause   VARCHAR2 (2000);
    BEGIN
       IF (    (emp_id IS NULL)
           AND (salary IS NULL)
           AND (job IS NULL)
           AND (deptIS NULL)
       THEN
          RETURN NULL;
       ELSE
          l_where_clause := 'WHERE ';
       END IF;
       IF (emp_id IS NOT NULL)
       THEN
          l_where_clause :=
                        l_where_clause || ' emp_id =' || emp_id || '';
       END IF;
       IF ((emp_id IS NOT NULL) AND (salary IS NOT NULL))
       THEN
          l_where_clause :=
                          l_where_clause || ' AND salary= ' || salary;
       ELSIF (salary IS NOT NULL)
       THEN
          l_where_clause := l_where_clause || ' salary= ' || salary;
       END IF;
       IF (((salary IS NOT NULL) AND (dept IS NOT NULL)) OR ((emp_id IS NOT NULL) AND (salary IS NULL) AND (dept IS NOT NULL)))
       THEN
          l_where_clause := l_where_clause || ' AND dept= ' || dept;
       ELSIF (status_i IS NOT NULL)
       THEN
          l_where_clause := l_where_clause || ' dept= ' || dept;
       END IF;
    l_where_clause := l_where_clause || ' ;';
       RETURN l_where_clause;
    END;I have done for three parameters, i need to include two more input parameters for this function, so I see going forward my testing cases will increases,
    so am looking for the best solution
    Thanks
    Edited by: NSK2KSN on Jul 7, 2010 3:11 PM

  • Filter not being generated into where clause

    Hi,
    I have a simple mapping that has a source table, a filter, and a target table that is set to DELETE. The source table has many rows, but the filter would narrow down these rows by a lot. When I generate the code, the cursor that gets created SELECTs the whole table then there is an IF statement that is applied to each row with the filter condition. A lot less processing would be required if the filter was implemented as a WHERE clause in the cursor, but I can't get it to generate this way. I realize that deletes automatically generate row-based code but it would still be row-based if the WHERE clause was in the cursor.
    Is there any way to get it to generate the filter as a WHERE clause in the cursor?

    Hi,
    In general, Warehouse Builder gives you a number of different operating modes:
    - set-based: which does everything in (one) SQL statement. This method is most performant, but has some limitations. Warehouse Builder today does not support set-based deletes (arguably, deletes are not the most common operation in a data warehouse).
    - row-based: which is optimal for debugging. In row-based mode, you get as many records as possible and all operations/transformations take place in PL/SQL. This option gives you most debugging capabilities.
    - row-based bulk: which is the previous method fetching rows in bulk (e.g. 100 by 100). Bulk processing speeds up the overall processing.
    - row-based target only: in this mode we push as many of the operations/transformations as possible into the query (cursor). I.e. your filter (in your case) would be implemented as a restriction on the filter.
    - row-based target only in bulk: see previous.
    Warehouse Builder's default operation is set-based fail over to row-based. I.e. because we do not support set-based delete statements, I suspect you fall back to the row-based method of execution, which is not ideal in your case. I suggest you use the row-based target only option in order to get optimal performance for your scenario.
    Note that for the deletes that are common in DW scenarios the row-based bulk deletes that we generate are often faster than set-based deletes. Also note that if you perform a complete delete (or even truncate) followed by an insert that Warehouse Builder does issue one statement for emptying the table.
    Thanks,
    Mark.

  • Urgent: Performance problem with where clause using IN and an OR condition

    Select statement is:
    select fl.feed_line_id
    from ap_expense_feed_lines_all fl
    where ((:1 is not null and
    fl.feed_line_id in (select distinct r2.object_id
    from xxdl_pcard_wf_routing_lists r2,
         per_people_f hr2
    where upper(hr2.full_name) like upper(:1||'%')
              and hr2.person_id = r2.person_id
    and r2.fyi_list is null
              and r2.sequence_number <> 0))
    or
    (:1 is null))
    If I modify the statement to remove the "or (:1 is null))" part at the bottom of the where clause, it returns in .16 seconds. If I modify the statement to only contain the "(:1 is null))" part of the where clause, it returns in .02 seconds. With the whole statement above, it returns in 477 seconds. Anyone have any suggestions?
    Explain plan for the whole statement is:
    (1) SELECT STATEMENT CHOOSE
    Est. Rows: 10,960 Cost: 212
    FILTER
    (2) TABLE ACCESS FULL AP.AP_EXPENSE_FEED_LINES_ALL [Analyzed]
    (2) Blocks: 8,610 Est. Rows: 10,960 of 209,260 Cost: 212
    Tablespace: APD
    (6) TABLE ACCESS BY INDEX ROWID HR.PER_ALL_PEOPLE_F [Analyzed]
    (6) Blocks: 4,580 Est. Rows: 1 of 85,500 Cost: 2
    Tablespace: HRD
    (5) NESTED LOOPS
    Est. Rows: 1 Cost: 4
    (3) TABLE ACCESS FULL XXDL.XXDL_PCARD_WF_ROUTING_LISTS [Analyzed]
    (3) Blocks: 19 Est. Rows: 1 of 1,303 Cost: 2
    Tablespace: XXDLD
    (4) UNIQUE INDEX RANGE SCAN HR.PER_PEOPLE_F_PK [Analyzed]
    Est. Rows: 1 Cost: 1
    Thanks in advance,
    Peter

    Thanks for the reply, but I have already checked what you are suggesting and I am pretty sure those are not causing the problem. The hr2.full_name column has an upper index and the (4) line of the explain plan shows that index being used. In addition, that part of the query executes on its own quickly.
    Because the sql is not displayed in an indented format on this page it is a little hard to understand the structure so I am going to restate what is happening.
    My sql is:
    select a_column
    from a_table
    where ((:1 is not null) and a_column in (sub-select statement)
    or
    (:1 is null))
    The :1 bind variable is set to a varchar2 entered on the screen of an application.
    If I execute either part of the sql without the OR condition, performance is good.
    If the :1 bind variable is null with the whole sql statement (so all rows or a_table are returned), performance is still good.
    If the :1 bind variable is a not-null value with the whole sql statement, performance stinks.
    As an example:
    where (('wa' is not null) and a_column in (sub-select statement)) -- fast
    where (('wa' is null)) -- fast
    where (('' is not null) and a_column in (sub-select statement) -- fast
    or
    ('' is null))
    where (('wa' is not null) and a_column in (sub-select statement) -- slow
    or
    ('wa' is null))

  • Issue with using N'...' values in a where clause against a function index

    We have a table that is defined with non Unicode columns with a UPPER(..) function index on the index column (to allow searching in any alphabetic case)
    e.g.
    create table my_table
    index_column varchar2(20),
    desc_column varchar2(40)
    create index my_table_idx as on my_table(UPPER(index_column));
    there is approx. > 10 million rows in this table
    The issue we have is that when we do the following select
    select index_column, desc_column from my_table
    where upper(index_column) = 'SOME VALUE'; this statement runs in approx 0.03 seconds which is great
    But we also have some statements that run as
    select index_column, desc_column from my_table
    where upper(index_column) = N'SOME VALUE'; notice the N'...' string (unicode) value used. This ends up doing a full table scan (> 5 seconds)
    So... the question is how can i make this select statement passing in a Unicode string value hit this function based UPPER index? Is there anyway?
    I have tried these extra indexes - to no avail
    create index my_table_idx as on my_table(UPPER(CAST(index_column as nvarchar2(20)));
    and
    create index my_table_idx as on my_table(UPPER(COMPOSE(index_column)));
    I assumed Oracle should have done and implicit conversion back to a non unicode string value and then passed that value into the UPPER(...) function index, but it appears as though Oracle isn't recognizing that the column is a different type (varchar2 vs nvarchar2)
    Any help greatly appreciated?

    Horrible amount of irrelevant tags, and the only thing relevant , the four digit version, is of course not mentioned.
    Also the characterset of the database is relevant.
    As far as I know in 11g and higher one no longer needs the N'<string construct>'
    As to implicit conversion
    assume <number_column> = '9'
    Oracle always converts this into
    to_char(<number_column>='9'
    Same applies to your case.
    Try leaving out the N, check whether it works and whether your function based index is used.
    Sybrand Bakker
    Senior Oracle DBA

  • Order by clause using decode function

    Hi everybody,
    i need below order in my report.
    Connecticut
    greenwich
    stamford
    bridgeport
    New York
    NYC
    wrestcher
    byram
    Georgia
    atlanta
    athens
    oconny
    first i need above order in my view out put.
    so in order by clause i used first decode function for State ordering
    and in second decode function for city ordering.
    i do not need order by ascending or descending.
    so pls anybody can help me.
    any help is greatly appreciated.
    thanks.

    add asc after the decode. default is desc

  • Where clause in COUNT function and joining two queries

    I have a table that I am trying to count the number of course passed, and also list the modules passed as well.
    the first problem I am having is what to put in the where variable , so that its not specific to a customer(I can use the query below for a particular customer and a particular course)but I will like a generic query where the result will be distinct in terms
    of user and course like the one below
    select FirstName,LastName,CourseTitle,Noofmodules, count (Coursecompleted) as modulescompleted from EStudentsprogress where Coursecompleted = '1'and EmailAddress = '[email protected]'
    and CourseTitle = 'Microsoft MOS 2010 EXCEL' Group by FirstName, LastName, CourseTitle, Noofmodules ;
    How can i make it list the result as above, whereby i dont specify the email address or course title(trying to get the result for all the clients )
    . Also I have a query that list the courses that is passed by the customer, I will like the column with the list of courses passed be added to the result above, but as a column for each course.
    select FirstName,LastName,CourseTitle, EmailAddress, CourseModule as coursepassed from EStudentsprogress where coursecompleted =1
    cheers

    Do you mean this?
    select FirstName,
    LastName,
    CourseTitle,
    Noofmodules,
    count (Coursecompleted) as modulescompleted,
    STUFF((SELECT ',' + CourseTitle
    FROM EStudentsprogress
    WHERE FirstName = e.FirstName
    AND LastName = e.LastName
    WHERE Coursecompleted = '1'
    FOR XML PATH('')),1,1,'') AS CoursesCompleted
    from EStudentsprogress e
    where Coursecompleted = '1'
    Group by FirstName, LastName, CourseTitle, Noofmodules ;
    If not please provide some sample data and explain the output you want
    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
    I AM HAVING Incorrect syntax near the keyword 'WHERE'. 
    It was a typo
    try this
    select FirstName,
    LastName,
    CourseTitle,
    Noofmodules,
    count (Coursecompleted) as modulescompleted,
    STUFF((SELECT ',' + CourseTitle
    FROM EStudentsprogress
    WHERE FirstName = e.FirstName
    AND LastName = e.LastName
    AND Coursecompleted = '1'
    FOR XML PATH('')),1,1,'') AS CoursesCompleted
    from EStudentsprogress e
    where Coursecompleted = '1'
    Group by FirstName, LastName, CourseTitle, Noofmodules ;
    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
    its populating all the result for a particular customer, so i added another clause to  it and it worked
    select FirstName,
    LastName,
    CourseTitle,
    Noofmodules, 
    count (Coursecompleted) as modulescompleted,
    STUFF((SELECT ','  + CourseTitle
    FROM EStudentsprogress 
    WHERE FirstName = e.FirstName
    AND LastName = e.LastName
    AND Coursecompleted = '1'
    AND CourseTitle = e.CourseTitle
    FOR XML PATH('')),1,1,'') AS CoursesCompleted
    from EStudentsprogress e
    where Coursecompleted = '1'
    Group by FirstName, LastName, CourseTitle, Noofmodules ;
    but the result of the column is long , so i tried to used the course module, which is a column with numbers, and i tried modifying the query , but i had Error converting data type varchar to float.( i checked and saw that stuff is for concatinating
    strings) is there a way around it.
    i used 
    select FirstName,
    LastName,
    CourseModule,
    CourseTitle,
    Noofmodules, 
    count (Coursecompleted) as modulescompleted,
    STUFF((SELECT ','  + CourseModule
    FROM EStudentsprogress 
    WHERE FirstName = e.FirstName
    AND LastName = e.LastName
    AND Coursecompleted = '1'
    AND CourseTitle = e.CourseTitle
    FOR XML PATH('')),1,1,'') AS CoursesCompleted
    from EStudentsprogress e
    where Coursecompleted = '1'
    Group by FirstName, LastName,CourseModule, CourseTitle, Noofmodules ;

  • Integer parameters not acceptible in WHERE clause with TO_DATE function.

    Please tell me why the following query is not acceptible in a BI Publisher (11.1.1.5) data set.
    SELECT * FROM all_tables
    WHERE
    LAST_ANALYZED >= TO_DATE(:yyyy || '-' || :startmo || '-' || :startday, 'YYYY-MM-DD')
    AND LAST_ANALYZED < TO_DATE(:yyyy || '-' || :endmo || '-' || :endday, 'YYYY-MM-DD')
    Attempting to save the query results in:
    "ORA-01858: a non-numeric character was found where a numeric was expected"
    It doesn't work even if you surround the parameters with TO_NUMBER().
    The query clearly works in SQL Developer.

    Also, neither of the following work, even though they both work in SQL Developer:
    SELECT table_name, last_analyzed
    FROM all_tables
    WHERE
    LAST_ANALYZED >= (TO_DATE(:start_date, 'MM-DD-YYYY') + 1)
    SELECT table_name, last_analyzed
    FROM all_tables
    WHERE
    LAST_ANALYZED >= (TO_DATE(:start_date, 'MM-DD-YYYY') + INTERVAL '1' DAY)
    These don't work in BIP even when the start_date parameter has a format set to the default MM-dd-yyyy. So to sum up, I can't use date parameters, nor can I use integers passed as date parts. What the fuck am I supposed to do?
    After four years, your fucking date parameters still don't work! Fuck off Oracle. I'm going home, frustrated with your garbage as usual.

  • Module_data where clause using globals.site.dateNow

    I'm trying (and failing) to get a list of blog posts that are excluding the not yet released posts, here is what I have:
    {module_data resource="blogposts" version="v3" fields="id,siteId,blogId,postTitle,createBy,releaseDate,createDate,lastUpdateDate,enabled ,deleted,disableComments,slug,postUrl,metaBlogPostTitle,metaBlogPostDescription" skip="0" limit="10" where="\{'blog.releaseDate':\{'$lt':'{{globals.site.dateNow}}'\}\}" order="-id" collection="myData"}
    The "query" works but it ignores the globals.site.dateNow and displays everything (including posts greater than today).
    If I do a greater than (in testing), it doesn't display anything, it should have only displayed the unreleased blog posts.
    Bug? User error? Formatting incorrect? Any tips would be great.

    Hi Rich,
    In your 'where' filter above, you are using, 'blog.releaseDate', if you want to filter the data based on the blog posts' release date then use 'releaseDate' only. Like this -
    where="\{'releaseDate':\{'$lt':'{{globals.site.dateNow}}'\}\}"
    Let me know if you need more clarification on this.
    - Abhishek Maurya

  • Toplink 10 where clause using + and -

    Hi all
    How do I in toplink 10 create a query similar to
    select *
    from t
    where t.a+t.b-t.c <> 0
    I've searched the Expression and ExpressionOperation classes but I can't find anything. Manythanks
    K

    There is an ExpressionMath class that allows for mathematical operations.
    i.e.
    Expression expression = ExpressionMath.add(builder.get("b"), builder.get("a"));

  • Use "ListContains' in a WHERE clause

    I believe I have a syntax problem and could you some help.
    First, I have a field in an Access DB called 'degree" that conatins
    a list of numbers. This list can be any combination of the numbers
    4 through 32. On my search page I have a selection box in a form to
    select a value of the degree to search for. The variable passed
    from the form is called "degreeValue". I have a component that lets
    me build my WHERE clause using several seach criteria. It functions
    perfectly prior to adding the search for "degree". I attempted to
    use "ListContains" in the WHERE clause using "degree" as the name
    of my list and "degreeValue" as my substring to search for. The
    error I get says that "variable degree is undefined". I am
    attaching the full code of the compoanent so you can see it. Again,
    it works if you take out the subclause build for "degree".

    I understand what you are saying and in other situations have
    done my tables that way. I didn't this time because this is one of
    those... "add it later" kind of things. Yes, the field does look
    like "1,2,3,4,etc.." The inventory a couple thousand items each
    with a number (catno). As you obviously noticed the inventory table
    houses most of the data for the items. The "degree" field in the
    past was only used to populate a series of checkboxes and was not
    searchable, thus a list was used.
    With a possibility of 29 values for "degree" and a
    possiblility of over 2,000 inventory items you can see a newly
    created table might become quite large. It would be nice if I could
    use the current structure.
    You are absolutely correct saying the design should be
    different. Thank you for your quick reply and good information.

Maybe you are looking for